svnno****@sourc*****
svnno****@sourc*****
Thu Feb 12 12:06:11 JST 2009
Revision: 3627 http://svn.sourceforge.jp/view?root=kazehakase&view=rev&rev=3627 Author: ikezoe Date: 2009-02-12 12:06:11 +0900 (Thu, 12 Feb 2009) Log Message: ----------- * src/bookmarks/kz-bookmark-folder.[ch]: Added KzBookmarkFolder object. * src/*: KzBookmarkFolder methods. This change will cause many regression. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/module/embed/gecko/Makefile.am kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp kazehakase/trunk/src/actions/kz-actions-dynamic.c kazehakase/trunk/src/actions/kz-actions.c kazehakase/trunk/src/actions/kz-smart-bookmark-action.c kazehakase/trunk/src/bookmarks/Makefile.am kazehakase/trunk/src/bookmarks/kz-actions-bookmark.c kazehakase/trunk/src/bookmarks/kz-bookmark-bar.c kazehakase/trunk/src/bookmarks/kz-bookmark-edit.c kazehakase/trunk/src/bookmarks/kz-bookmark-file.c kazehakase/trunk/src/bookmarks/kz-bookmark-file.h kazehakase/trunk/src/bookmarks/kz-bookmark-item.c kazehakase/trunk/src/bookmarks/kz-bookmark-menu-item-list.c kazehakase/trunk/src/bookmarks/kz-bookmark-menu.c kazehakase/trunk/src/bookmarks/kz-bookmark-tab-menu.c kazehakase/trunk/src/bookmarks/kz-bookmark.c kazehakase/trunk/src/bookmarks/kz-bookmark.h kazehakase/trunk/src/bookmarks/kz-bookmarks-view.c kazehakase/trunk/src/bookmarks/kz-hinadi.c kazehakase/trunk/src/bookmarks/kz-history.c kazehakase/trunk/src/bookmarks/kz-lirs.c kazehakase/trunk/src/bookmarks/kz-nsbookmark.c kazehakase/trunk/src/bookmarks/kz-proxy-folder.c kazehakase/trunk/src/bookmarks/kz-proxy-folder.h kazehakase/trunk/src/bookmarks/kz-root-bookmark.c kazehakase/trunk/src/bookmarks/kz-root-bookmark.h kazehakase/trunk/src/bookmarks/kz-rss.c kazehakase/trunk/src/bookmarks/kz-smart-bookmark.c kazehakase/trunk/src/bookmarks/kz-smart-bookmark.h kazehakase/trunk/src/bookmarks/kz-w3mbookmark.c kazehakase/trunk/src/bookmarks/kz-xbel.c kazehakase/trunk/src/kz-app.c kazehakase/trunk/src/kz-embed.c kazehakase/trunk/src/kz-navi.c kazehakase/trunk/src/kz-notebook.c kazehakase/trunk/src/kz-popup-tablist.c kazehakase/trunk/src/kz-tab-label.c kazehakase/trunk/src/kz-thumbnails-view.c kazehakase/trunk/src/kz-window.c kazehakase/trunk/src/sidebar/kz-thumbnails-sidebar.c Added Paths: ----------- kazehakase/trunk/src/bookmarks/kz-bookmark-folder.c kazehakase/trunk/src/bookmarks/kz-bookmark-folder.h Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/ChangeLog 2009-02-12 03:06:11 UTC (rev 3627) @@ -1,6 +1,10 @@ 2009-02-12 Hiroyuki Ikezoe <poinc****@ikezo*****> * configure.ac: Require GtkIEEmbed-0.9.1. + * src/bookmarks/kz-bookmark-folder.[ch]: Added KzBookmarkFolder + object. + * src/*: KzBookmarkFolder methods. This change will cause many + regression. 2009-02-11 Hiroyuki Ikezoe <poinc****@ikezo*****> Modified: kazehakase/trunk/module/embed/gecko/Makefile.am =================================================================== --- kazehakase/trunk/module/embed/gecko/Makefile.am 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/module/embed/gecko/Makefile.am 2009-02-12 03:06:11 UTC (rev 3627) @@ -61,7 +61,6 @@ -I$(MOZILLA_INCLUDE_ROOT)/windowwatcher \ -I$(MOZILLA_INCLUDE_ROOT)/xmlextras \ -I$(MOZILLA_INCLUDE_ROOT)/xpcom \ - $(GTK_CFLAGS) \ -I$(top_builddir)/src \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/bookmarks \ @@ -110,13 +109,13 @@ $(LIBTOOL_EXPORT_OPTIONS) gecko_la_CPPFLAGS = \ - -DGTK_DISABLE_DEPRECATED=1 \ - -DGDK_DISABLE_DEPRECATED=1 \ -DMOZILLA_HOME=\"$(MOZILLA_HOME)\" \ -DMOZILLA_PREFIX=\"$(MOZILLA_PREFIX)\" \ -DGECKO_VERSION=\"$(GECKO_VERSION)\" \ -DG_LOG_DOMAIN=\"Kazehakase-Gecko\" \ - -DG_DISABLE_DEPRECATED=1 + -DG_DISABLE_DEPRECATED=1 \ + $(GTK_CFLAGS) \ + $(COVERAGE_CFLAGS) if ENABLE_GTKMOZEMBED GTKMOZEMBED_CFLAGS += -I$(top_srcdir)/module/embed/gecko/gtkmozembed Modified: kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp 2009-02-12 03:06:11 UTC (rev 3627) @@ -2982,7 +2982,7 @@ sHistory->PurgeHistory(n); GList *children, *node; - children = kz_bookmark_get_children(history); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(history)); for (node = children; node; node = g_list_next (node)) { KzBookmark *child = KZ_BOOKMARK(node->data); @@ -3004,7 +3004,7 @@ g_list_free(children); /* set current */ - gint cur = kz_bookmark_get_current(history); + gint cur = kz_bookmark_folder_get_current_position(KZ_BOOKMARK_FOLDER(history)); go_history_index(kzembed, cur); } @@ -3025,7 +3025,7 @@ if (NS_FAILED(rv) || !sHistory) return; GList *children, *tab; - children = kz_bookmark_get_children(history); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(history)); tab = children; PRInt32 count; @@ -3049,7 +3049,7 @@ if (!bookmark) { bookmark = kz_bookmark_new_with_attrs(title, uri, NULL); - kz_bookmark_append(history, bookmark); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(history), bookmark); g_object_unref(bookmark); } else if (uri && !strcmp(uri, kz_bookmark_get_link(bookmark))) @@ -3078,14 +3078,14 @@ { KzBookmark *child = KZ_BOOKMARK(tab->data); prev = g_list_previous(tab); - kz_bookmark_remove (history, child); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(history), child); tab = prev; } if (children) g_list_free(children); - kz_bookmark_set_current(history, (gint)index); + kz_bookmark_folder_set_current_position(KZ_BOOKMARK_FOLDER(history), (gint)index); } Modified: kazehakase/trunk/src/actions/kz-actions-dynamic.c =================================================================== --- kazehakase/trunk/src/actions/kz-actions-dynamic.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/actions/kz-actions-dynamic.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -337,7 +337,7 @@ gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu), smart_bookmark_submenu); gtk_widget_show(smart_bookmark_submenu); - children = kz_bookmark_get_children(bookmark); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(bookmark)); for (node = children; node; node = g_list_next(node)) { GList *sub_children, *sub_node; @@ -362,7 +362,7 @@ gtk_widget_show(sub_folder); gtk_widget_show(menuitem); - sub_children = kz_bookmark_get_children(child); + sub_children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(child)); for (sub_node = sub_children; sub_node; Modified: kazehakase/trunk/src/actions/kz-actions.c =================================================================== --- kazehakase/trunk/src/actions/kz-actions.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/actions/kz-actions.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -40,6 +40,7 @@ #include "kz-bookmark-edit-win.h" #include "kz-bookmark-filter.h" #include "kz-bookmark-file.h" +#include "kz-bookmark-folder.h" #include "kz-entry-action.h" #include "kz-location-entry-action.h" #include "kz-navigation-action.h" @@ -968,7 +969,7 @@ g_return_if_fail(KZ_IS_BOOKMARK(folder)); g_return_if_fail(kz_bookmark_is_folder(folder)); - children = kz_bookmark_get_children(folder); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(folder)); for (node = children; node; node = g_list_next(node)) { KzBookmark *item = node->data; @@ -1078,9 +1079,9 @@ bookmark = kz_bookmark_new_with_attrs(title, uri, desc); /* FIXME! show dialog */ if (sibling) - kz_bookmark_insert_before(folder, bookmark, sibling); + kz_bookmark_folder_insert_before(KZ_BOOKMARK_FOLDER(folder), bookmark, sibling); else - kz_bookmark_append(folder, bookmark); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(folder), bookmark); if (KZ_IS_BOOKMARK_FILE(folder)) file = folder; @@ -1149,7 +1150,7 @@ bookmark); } - kz_bookmark_remove(folder, bookmark); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(folder), bookmark); if (!has_xmlrpc) kz_bookmark_file_save(KZ_BOOKMARK_FILE(file)); @@ -1312,7 +1313,7 @@ /* set the original URI */ kz_bookmark_file_set_location(KZ_BOOKMARK_FILE(bookmark), uri); - kz_bookmark_prepend(clip, bookmark); + kz_bookmark_folder_prepend(KZ_BOOKMARK_FOLDER(clip), bookmark); kz_bookmark_file_save(KZ_BOOKMARK_FILE(clip)); g_free(link); @@ -1655,7 +1656,7 @@ if (!kz->popup_tablist) kz->popup_tablist = kz_popup_tablist_new(kz); - proxy = kz_proxy_folder_new(kz->tabs); + proxy = kz_proxy_folder_new(KZ_BOOKMARK_FOLDER(kz->tabs)); g_signal_connect(kz->popup_tablist, "selected", G_CALLBACK(cb_thumbnail_tablist_selected), kz); /* to keep KzPopupTablist from adhering to KzWindow, I can't pass KzWindow to KzPopupTablist directly... */ @@ -1945,7 +1946,7 @@ has_link = kz_bookmark_get_link(bookmark) ? TRUE : FALSE; is_folder = kz_bookmark_is_folder(bookmark); is_file = KZ_IS_BOOKMARK_FILE(bookmark); - has_children = kz_bookmark_has_children(bookmark); + has_children = kz_bookmark_folder_has_children(KZ_BOOKMARK_FOLDER(bookmark)); is_editable = kz_bookmark_is_editable(bookmark); if (is_file) children_is_editable = kz_bookmark_file_is_editable(KZ_BOOKMARK_FILE(bookmark)); @@ -2596,7 +2597,7 @@ { GList *children, *node; - children = kz_bookmark_get_children(bookmark); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(bookmark)); for (node = children; node; node = g_list_next(node)) { gpointer p; @@ -2679,7 +2680,7 @@ { GList *children, *node; - children = kz_bookmark_get_children(bookmark); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(bookmark)); for (node = children; node; node = g_list_next(node)) { gpointer p; Modified: kazehakase/trunk/src/actions/kz-smart-bookmark-action.c =================================================================== --- kazehakase/trunk/src/actions/kz-smart-bookmark-action.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/actions/kz-smart-bookmark-action.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -32,6 +32,7 @@ #include "kz-entry.h" #include "kz-actions.h" #include "kz-icons.h" +#include "kz-bookmark-folder.h" #define KZ_SMART_BOOKMARK_ACTION_BOOKMARK_KEY "KzSmartBookmarkAction::Bookmark" @@ -73,12 +74,12 @@ static void cb_bookmark_notify (GObject *object, GParamSpec *pspec, KzSmartBookmarkAction *action); -static void cb_bookmark_updated (KzBookmark *folder, +static void cb_bookmark_updated (KzBookmarkFolder *folder, KzSmartBookmarkAction *action); -static void cb_bookmark_remove_child (KzBookmark *folder, +static void cb_bookmark_remove_child (KzBookmarkFolder *folder, KzBookmark *child, KzSmartBookmarkAction *action); -static void cb_bookmark_insert_child (KzBookmark *folder, +static void cb_bookmark_insert_child (KzBookmarkFolder *folder, KzBookmark *child, KzBookmark *sibling, KzSmartBookmarkAction *action); @@ -202,7 +203,7 @@ /* if bookmark is a folder, connect signals */ if (kz_bookmark_is_folder(action->bookmark)) { - cb_bookmark_updated(action->bookmark, action); + cb_bookmark_updated(KZ_BOOKMARK_FOLDER(action->bookmark), action); /* g_signal_connect(bookmark, "children-reordered", G_CALLBACK(cb_bookmark_updated), action);*/ @@ -567,7 +568,7 @@ } static void -cb_bookmark_updated (KzBookmark *folder, KzSmartBookmarkAction *action) +cb_bookmark_updated (KzBookmarkFolder *folder, KzSmartBookmarkAction *action) { GList *children, *node; GtkWidget *menuitem; @@ -579,7 +580,7 @@ action->menu = gtk_menu_new(); /* folder menu */ - menuitem = create_menu_item(action, folder); + menuitem = create_menu_item(action, KZ_BOOKMARK(folder)); gtk_menu_shell_append(GTK_MENU_SHELL(action->menu), menuitem); if (action->menulist) @@ -589,8 +590,8 @@ update_icon_and_bgtext(action); /* children */ - children = kz_bookmark_get_children(folder); - folder_pos = kz_bookmark_get_current(folder); + children = kz_bookmark_folder_get_children(folder); + folder_pos = kz_bookmark_folder_get_current_position(folder); for (node = children, i = 0; node; node = g_list_next(node), i++) { KzBookmark *child = node->data; @@ -610,7 +611,7 @@ static void -cb_bookmark_remove_child (KzBookmark *folder, +cb_bookmark_remove_child (KzBookmarkFolder *folder, KzBookmark *child, KzSmartBookmarkAction *action) { @@ -618,7 +619,7 @@ GtkWidget *widget; gint pos; - children = kz_bookmark_get_children(folder); + children = kz_bookmark_folder_get_children(folder); if (!children) return; menuitems = gtk_container_get_children(GTK_CONTAINER(action->menu)); @@ -646,7 +647,7 @@ static void -cb_bookmark_insert_child (KzBookmark *folder, +cb_bookmark_insert_child (KzBookmarkFolder *folder, KzBookmark *child, KzBookmark *sibling, KzSmartBookmarkAction *action) @@ -663,9 +664,9 @@ GList *children; guint pos; - children = kz_bookmark_get_children(folder); + children = kz_bookmark_folder_get_children(folder); pos = g_list_index(children, child); - if (pos < kz_bookmark_get_current(folder)) + if (pos < kz_bookmark_folder_get_current_position(folder)) insert_child(action, child, menuitem, pos); else insert_child(action, child, menuitem, pos + 1); @@ -675,13 +676,13 @@ { GList *children; gint pos; - children = kz_bookmark_get_children(folder); + children = kz_bookmark_folder_get_children(folder); pos = g_list_index(children, sibling); gtk_menu_shell_insert(GTK_MENU_SHELL(action->menu), menuitem, pos - 1); action->menulist = g_list_insert(action->menulist, child, pos - 1); - kz_bookmark_set_current(folder, pos); + kz_bookmark_folder_set_current_position(folder, pos); if (pos == 1) { @@ -715,7 +716,7 @@ bookmark); action->menulist = g_list_prepend(action->menulist, bookmark); - kz_bookmark_set_current(bookmark, 0); + kz_bookmark_folder_set_current_position(KZ_BOOKMARK_FOLDER(bookmark), 0); update_icon_and_bgtext(action); return; } @@ -724,14 +725,14 @@ /* remove bookmark */ g_object_ref(bookmark); - kz_bookmark_remove(parent, bookmark); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(parent), bookmark); /* insert bookmark */ - kz_bookmark_prepend(parent, bookmark); + kz_bookmark_folder_prepend(KZ_BOOKMARK_FOLDER(parent), bookmark); /* now, current bookmark is top of the parent */ - kz_bookmark_set_current(parent, - g_list_index(action->menulist, parent)); + kz_bookmark_folder_set_current_position(KZ_BOOKMARK_FOLDER(parent), + g_list_index(action->menulist, parent)); g_object_unref(bookmark); } @@ -814,7 +815,7 @@ g_return_val_if_fail(kz_bookmark_is_folder(bookmark), NULL); - children = kz_bookmark_get_children(bookmark); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(bookmark)); if (!children) return NULL; n_children = g_list_length(children); Modified: kazehakase/trunk/src/bookmarks/Makefile.am =================================================================== --- kazehakase/trunk/src/bookmarks/Makefile.am 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/Makefile.am 2009-02-12 03:06:11 UTC (rev 3627) @@ -2,6 +2,10 @@ noinst_LTLIBRARIES = libkzbookmarks.la +AM_CFLAGS = \ + $(GTK_CFLAGS) \ + $(COVERAGE_CFLAGS) + INCLUDES = \ -I$(top_builddir)/src \ -I$(top_srcdir)/src/actions \ @@ -31,6 +35,7 @@ kz-bookmark-file.h \ kz-bookmark-separator.h \ kz-bookmark-filter.h \ + kz-bookmark-folder.h \ kz-bookmark-bar.h \ kz-bookmark-item.h \ kz-bookmark-menu.h \ @@ -69,6 +74,7 @@ kz-root-bookmark.c \ kz-smart-bookmark.c \ kz-bookmark-file.c \ + kz-bookmark-folder.c \ kz-bookmark-separator.c \ kz-bookmark-filter.c \ kz-bookmark-bar.c \ Modified: kazehakase/trunk/src/bookmarks/kz-actions-bookmark.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-actions-bookmark.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-actions-bookmark.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -99,7 +99,7 @@ sibling = NULL; } - kz_bookmark_insert_before(parent, bookmark, sibling); + kz_bookmark_folder_insert_before(KZ_BOOKMARK_FOLDER(parent), bookmark, sibling); if (KZ_IS_BOOKMARK_FILE(parent)) file = parent; @@ -142,7 +142,7 @@ g_return_if_fail(GTK_IS_ACTION(action)); g_return_if_fail(KZ_IS_BOOKMARK_EDITOR(editor)); - folder = kz_bookmark_pure_folder_new(); + folder = kz_bookmark_folder_new(); kz_bookmark_set_title(folder, _("New folder")); insert_bookmark_item(editor, folder); g_object_unref(folder); @@ -324,7 +324,7 @@ bookmark = node->data; if (!KZ_IS_BOOKMARK(bookmark)) continue; - kz_bookmark_remove(parent, bookmark); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(parent), bookmark); if (KZ_IS_BOOKMARK_FILE(parent)) file = parent; Modified: kazehakase/trunk/src/bookmarks/kz-bookmark-bar.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark-bar.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-bookmark-bar.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -347,7 +347,7 @@ gtk_container_foreach (GTK_CONTAINER (GTK_TOOLBAR(bar->toolbar)), remove_item, NULL); - children = kz_bookmark_get_children(bar->folder); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(bar->folder)); for (node = children; node; node = g_list_next(node)) { GtkToolItem *toolitem; @@ -412,7 +412,7 @@ index = gtk_toolbar_get_drop_index(GTK_TOOLBAR(bar->toolbar), x, y); - children = kz_bookmark_get_children(bar->folder); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(bar->folder)); sibling = g_list_nth_data(children, index); g_list_free(children); @@ -446,7 +446,7 @@ g_object_ref(bookmark); parent = kz_bookmark_get_parent(bookmark); - kz_bookmark_remove(parent, bookmark); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(parent), bookmark); moved = TRUE; break; case TARGET_NETSCAPE_URL: @@ -461,13 +461,13 @@ { if (sibling) { - kz_bookmark_insert_before(bar->folder, + kz_bookmark_folder_insert_before(KZ_BOOKMARK_FOLDER(bar->folder), bookmark, sibling); } else { - kz_bookmark_append(bar->folder, bookmark); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(bar->folder), bookmark); } g_object_unref(bookmark); kz_bookmark_file_save(KZ_BOOKMARK_FILE(bar->folder)); @@ -555,7 +555,7 @@ if (sibling) { - children = kz_bookmark_get_children(folder); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(folder)); index = g_list_index(children, sibling); g_list_free(children); } @@ -579,7 +579,7 @@ g_return_if_fail(KZ_IS_BOOKMARK(child)); g_return_if_fail(KZ_IS_BOOKMARK_BAR(bar)); - children = kz_bookmark_get_children(folder); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(folder)); index = g_list_index(children, child); g_list_free(children); Modified: kazehakase/trunk/src/bookmarks/kz-bookmark-edit.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark-edit.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-bookmark-edit.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -430,7 +430,7 @@ kz_bookmark_edit_set_sensitive (KzBookmarkEdit *edit) { gboolean can_edit_title = TRUE; - gboolean can_edit_uri = TRUE; + gboolean can_edit_uri = FALSE; gboolean can_edit_desc = TRUE; gboolean can_edit_location = FALSE; gboolean can_edit_interval = FALSE; @@ -443,19 +443,15 @@ kz_bookmark_is_separator(edit->bookmark)) { can_edit_title = FALSE; - can_edit_uri = FALSE; can_edit_desc = FALSE; can_edit_location = FALSE; can_edit_interval = FALSE; } - else if (edit->bookmark && kz_bookmark_is_pure_folder(edit->bookmark)) - { - can_edit_uri = FALSE; - } if (edit->bookmark && KZ_IS_BOOKMARK_FILE(edit->bookmark)) { can_edit_location = TRUE; can_edit_interval = TRUE; + can_edit_uri = TRUE; } gtk_editable_set_editable(GTK_EDITABLE(edit->title_entry), @@ -491,7 +487,7 @@ else { if (edit->bookmark && - kz_bookmark_is_pure_folder(edit->bookmark)) + KZ_IS_BOOKMARK_FOLDER(edit->bookmark)) { gtk_widget_hide(edit->uri_label); gtk_widget_hide(edit->uri_entry); Modified: kazehakase/trunk/src/bookmarks/kz-bookmark-file.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark-file.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-bookmark-file.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -114,7 +114,7 @@ static GQuark io_signal_id_quark = 0; static GQuark p_last_modified_quark = 0; -G_DEFINE_TYPE(KzBookmarkFile, kz_bookmark_file, KZ_TYPE_BOOKMARK) +G_DEFINE_TYPE(KzBookmarkFile, kz_bookmark_file, KZ_TYPE_BOOKMARK_FOLDER) static void kz_bookmark_file_class_init (KzBookmarkFileClass *klass) @@ -720,7 +720,7 @@ kz_bookmark_file_signals[LOAD_START_SIGNAL], 0); - kz_bookmark_remove_all(KZ_BOOKMARK(bookmark_file)); + kz_bookmark_folder_remove_all(KZ_BOOKMARK_FOLDER(bookmark_file)); io = kz_io_new(uri); id = g_signal_connect(io, "io_completed", @@ -956,13 +956,14 @@ g_return_val_if_fail(KZ_IS_BOOKMARK(bookmark), FALSE); /* check loading state */ - children = kz_bookmark_get_children(bookmark); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(bookmark)); node = children; while (node) { KzBookmark *child = node->data; - if (kz_bookmark_has_children(child)) + if (KZ_IS_BOOKMARK_FOLDER(child) && + kz_bookmark_folder_has_children(KZ_BOOKMARK_FOLDER(child))) { ret = kz_bookmark_file_is_loading_all_children(child); if (ret) break; Modified: kazehakase/trunk/src/bookmarks/kz-bookmark-file.h =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark-file.h 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-bookmark-file.h 2009-02-12 03:06:11 UTC (rev 3627) @@ -25,7 +25,7 @@ #define __KZ_BOOKMARK_FILE_H__ #include <glib-object.h> -#include "kz-bookmark.h" +#include "kz-bookmark-folder.h" G_BEGIN_DECLS @@ -54,13 +54,13 @@ struct _KzBookmarkFile { - KzBookmark parent; + KzBookmarkFolder parent; KzBookmarkFileFlag flags; }; struct _KzBookmarkFileClass { - KzBookmarkClass parent_class; + KzBookmarkFolderClass parent_class; /* -- signals -- */ Added: kazehakase/trunk/src/bookmarks/kz-bookmark-folder.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark-folder.c (rev 0) +++ kazehakase/trunk/src/bookmarks/kz-bookmark-folder.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -0,0 +1,566 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* + * Copyright (C) 2003 Hiroyuki Ikezoe + * Copyright (C) 2003 Takuro Ashie + * + * This program 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 2, or (at your option) + * any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#include "kz-bookmark-folder.h" + +#include <string.h> +#include <gtk/gtk.h> +#include <glib/gi18n.h> +#include "glib-utils.h" +#include "kz-marshalers.h" +#include "utils.h" +#include "kz-bookmark-file.h" +#include "kz-bookmarks-enum-types.h" + +enum { + INSERT_CHILD_SIGNAL, + REMOVE_CHILD_SIGNAL, + MOVE_CHILD_SIGNAL, + CHILDREN_REORDERED_SIGNAL, + GET_CHILDREN_SIGNAL, + HAS_CHILDREN_SIGNAL, + LAST_SIGNAL +}; + +enum { + PROP_0, + PROP_INTERVAL, + PROP_CURRENT_POSITION, + PROP_LOCK, + PROP_AUTO_REFRESH, + PROP_ENABLE_JAVASCRIPT +}; + +typedef struct _KzBookmarkFolderPrivate KzBookmarkFolderPrivate; +struct _KzBookmarkFolderPrivate +{ + GList *children; + guint current_position; + gboolean folded; + gboolean locked; + gboolean auto_refresh; + gboolean enable_javascript; +}; +#define KZ_BOOKMARK_FOLDER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KZ_TYPE_BOOKMARK_FOLDER, KzBookmarkFolderPrivate)) + +static void dispose (GObject *object); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); + +static gint signals[LAST_SIGNAL] = {0}; + +G_DEFINE_TYPE(KzBookmarkFolder, kz_bookmark_folder, KZ_TYPE_BOOKMARK); + +static void +kz_bookmark_folder_class_init (KzBookmarkFolderClass *klass) +{ + GObjectClass *object_class; + + object_class = (GObjectClass *) klass; + + object_class->dispose = dispose; + object_class->set_property = set_property; + object_class->get_property = get_property; + + g_object_class_install_property( + object_class, + PROP_CURRENT_POSITION, + g_param_spec_uint( + "current-position", + _("Current Position"), + _("Current position in history"), + 0, + G_MAXUINT, + 0, + G_PARAM_READWRITE)); + + g_object_class_install_property( + object_class, + PROP_LOCK, + g_param_spec_boolean( + "lock", + _("Lock state"), + _("Lock state for tab"), + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property( + object_class, + PROP_AUTO_REFRESH, + g_param_spec_boolean( + "auto-refresh", + _("Auto Refresh state"), + _("Auto Refresh state for tab"), + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property( + object_class, + PROP_ENABLE_JAVASCRIPT, + g_param_spec_boolean( + "enable-javascript", + _("Javascript state"), + _("Javascript state for tab"), + FALSE, + G_PARAM_READWRITE)); + + signals[INSERT_CHILD_SIGNAL] + = g_signal_new ("insert-child", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (KzBookmarkFolderClass, insert_child), + NULL, NULL, + _kz_marshal_VOID__OBJECT_OBJECT, + G_TYPE_NONE, 2, + KZ_TYPE_BOOKMARK, KZ_TYPE_BOOKMARK); + + signals[REMOVE_CHILD_SIGNAL] + = g_signal_new ("remove-child", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (KzBookmarkFolderClass, remove_child), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + KZ_TYPE_BOOKMARK); + + signals[MOVE_CHILD_SIGNAL] + = g_signal_new ("move-child", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (KzBookmarkFolderClass, move_child), + NULL, NULL, + _kz_marshal_VOID__OBJECT_OBJECT, + G_TYPE_NONE, 2, + KZ_TYPE_BOOKMARK, KZ_TYPE_BOOKMARK); + + signals[CHILDREN_REORDERED_SIGNAL] + = g_signal_new ("children-reordered", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (KzBookmarkFolderClass, + children_reordered), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[GET_CHILDREN_SIGNAL] + = g_signal_new ("get-children", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (KzBookmarkFolderClass, get_children), + NULL, NULL, + _kz_marshal_POINTER__VOID, + G_TYPE_POINTER, 0); + + signals[HAS_CHILDREN_SIGNAL] + = g_signal_new ("has-children", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (KzBookmarkFolderClass, has_children), + NULL, NULL, + _kz_marshal_BOOLEAN__VOID, + G_TYPE_BOOLEAN, 0); + + g_type_class_add_private(object_class, sizeof(KzBookmarkFolderPrivate)); +} + +static void +kz_bookmark_folder_init (KzBookmarkFolder *folder) +{ + KzBookmarkFolderPrivate *priv = KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder); + + priv->children = NULL; + priv->folded = TRUE; + priv->current_position = 0; + priv->locked = FALSE; + priv->auto_refresh = FALSE; + priv->enable_javascript = TRUE; +} + +static void +dispose (GObject *object) +{ + kz_bookmark_folder_remove_all(KZ_BOOKMARK_FOLDER(object)); + + if (G_OBJECT_CLASS (kz_bookmark_folder_parent_class)->dispose) + G_OBJECT_CLASS (kz_bookmark_folder_parent_class)->dispose(object); +} + +static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + KzBookmarkFolderPrivate *priv = KZ_BOOKMARK_FOLDER_GET_PRIVATE(object); + + switch (prop_id) { + case PROP_CURRENT_POSITION: + priv->current_position = g_value_get_uint(value); + break; + case PROP_LOCK: + priv->locked = g_value_get_boolean(value); + break; + case PROP_AUTO_REFRESH: + priv->auto_refresh = g_value_get_boolean(value); + break; + case PROP_ENABLE_JAVASCRIPT: + priv->enable_javascript = g_value_get_boolean(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + KzBookmarkFolderPrivate *priv = KZ_BOOKMARK_FOLDER_GET_PRIVATE(object); + + switch (prop_id) { + case PROP_CURRENT_POSITION: + g_value_set_uint(value, priv->current_position); + break; + case PROP_LOCK: + g_value_set_boolean(value, priv->locked); + break; + case PROP_AUTO_REFRESH: + g_value_set_boolean(value, priv->auto_refresh); + break; + case PROP_ENABLE_JAVASCRIPT: + g_value_set_boolean(value, priv->enable_javascript); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +KzBookmark * +kz_bookmark_folder_new (void) +{ + return KZ_BOOKMARK(g_object_new(KZ_TYPE_BOOKMARK_FOLDER, NULL)); +} + +gboolean +kz_bookmark_folder_get_folded (KzBookmarkFolder *folder) +{ + g_return_val_if_fail(KZ_IS_BOOKMARK_FOLDER(folder), FALSE); + + return KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder)->folded; +} + +void +kz_bookmark_folder_set_folded (KzBookmarkFolder *folder, gboolean folded) +{ + g_return_if_fail(KZ_IS_BOOKMARK_FOLDER(folder)); + + KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder)->folded = folded; +} + +void +kz_bookmark_folder_insert_before (KzBookmarkFolder *folder, + KzBookmark *child, + KzBookmark *sibling) +{ + KzBookmarkFolderPrivate *priv; + GList *next = NULL; + + g_return_if_fail(KZ_IS_BOOKMARK_FOLDER(folder)); + + priv = KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder); + if (sibling) + next = g_list_find(priv->children, sibling); + + g_object_ref(child); + priv->children = g_list_insert_before(priv->children, next, child); + + kz_bookmark_set_parent(child, KZ_BOOKMARK(folder)); + g_signal_emit(folder, signals[INSERT_CHILD_SIGNAL], 0, + child, sibling); +} + + +void +kz_bookmark_folder_append (KzBookmarkFolder *folder, KzBookmark *child) +{ + kz_bookmark_folder_insert_before(folder, child, NULL); +} + +void +kz_bookmark_folder_prepend (KzBookmarkFolder *folder, KzBookmark *child) +{ + KzBookmarkFolderPrivate *priv; + + g_return_if_fail(KZ_IS_BOOKMARK_FOLDER(folder)); + + priv = KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder); + + g_object_ref(child); + priv->children = g_list_prepend(priv->children, child); + + kz_bookmark_set_parent(child, KZ_BOOKMARK(folder)); + g_signal_emit(folder, signals[INSERT_CHILD_SIGNAL], 0, + child, NULL); +} + +void +kz_bookmark_folder_remove (KzBookmarkFolder *folder, KzBookmark *child) +{ + KzBookmarkFolderPrivate *priv; + + g_return_if_fail(KZ_IS_BOOKMARK_FOLDER(folder)); + + priv = KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder); + if (!g_list_find(priv->children, child)) + return; + + priv->children = g_list_remove(priv->children, child); + g_object_unref(child); + + g_signal_emit(folder, signals[REMOVE_CHILD_SIGNAL], 0, child); +} + + +void +kz_bookmark_folder_remove_all (KzBookmarkFolder *folder) +{ + GList *children, *node, *prev; + KzBookmarkFolderPrivate *priv; + + g_return_if_fail(KZ_IS_BOOKMARK_FOLDER(folder)); + + priv = KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder); + children = g_list_copy(priv->children); + + node = g_list_last(children); + while (node) + { + KzBookmark *child = node->data; + prev = g_list_previous(node); + kz_bookmark_folder_remove(folder, child); + node = prev; + } + + g_list_free(children); +} + +GList * +kz_bookmark_folder_get_children (KzBookmarkFolder *folder) +{ + g_return_val_if_fail(KZ_IS_BOOKMARK_FOLDER(folder), NULL); + + return g_list_copy(KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder)->children); +} + +gboolean +kz_bookmark_folder_has_children (KzBookmarkFolder *folder) +{ + g_return_val_if_fail(KZ_IS_BOOKMARK_FOLDER(folder), FALSE); + + return (KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder)->children != NULL); +} + +/* return current activate tab position */ +guint +kz_bookmark_folder_get_current_position (KzBookmarkFolder *folder) +{ + g_return_val_if_fail(KZ_IS_BOOKMARK_FOLDER(folder), 0); + + return KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder)->current_position; +} +void +kz_bookmark_folder_set_current_position (KzBookmarkFolder *folder, guint pos) +{ + g_return_if_fail(KZ_IS_BOOKMARK_FOLDER(folder)); + + KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder)->current_position = pos; + g_object_notify(G_OBJECT(folder), "current-position"); +} + +KzBookmark * +kz_bookmark_folder_get_current_bookmark (KzBookmarkFolder *folder) +{ + gpointer *current_bookmark; + + g_return_val_if_fail(KZ_IS_BOOKMARK_FOLDER(folder), NULL); + + current_bookmark = g_list_nth_data(KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder)->children, + kz_bookmark_folder_get_current_position(folder)); + + return current_bookmark ? KZ_BOOKMARK(current_bookmark) : NULL; +} + +gboolean +kz_bookmark_folder_get_lock (KzBookmarkFolder *folder) +{ + g_return_val_if_fail(KZ_IS_BOOKMARK_FOLDER(folder), FALSE); + + return KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder)->locked; +} + +void +kz_bookmark_folder_set_lock (KzBookmarkFolder *folder, + gboolean lock) +{ + g_return_if_fail(KZ_IS_BOOKMARK_FOLDER(folder)); + + KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder)->locked = lock; + g_object_notify(G_OBJECT(folder), "lock"); +} + +gboolean +kz_bookmark_folder_get_auto_refresh (KzBookmarkFolder *folder) +{ + g_return_val_if_fail(KZ_IS_BOOKMARK_FOLDER(folder), FALSE); + + return KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder)->auto_refresh; +} + +void +kz_bookmark_folder_set_auto_refresh (KzBookmarkFolder *folder, + gboolean auto_refresh) +{ + g_return_if_fail(KZ_IS_BOOKMARK_FOLDER(folder)); + + KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder)->auto_refresh = auto_refresh; + g_object_notify(G_OBJECT(folder), "auto-refresh"); +} + +gboolean +kz_bookmark_folder_get_javascript (KzBookmarkFolder *folder) +{ + g_return_val_if_fail(KZ_IS_BOOKMARK_FOLDER(folder), FALSE); + + return KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder)->enable_javascript; +} + +void +kz_bookmark_folder_set_javascript (KzBookmarkFolder *folder, + gboolean javascript) +{ + g_return_if_fail(KZ_IS_BOOKMARK_FOLDER(folder)); + + KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder)->enable_javascript = javascript; + g_object_notify(G_OBJECT(folder), "enable-javascript"); +} + +static gint +compare_func (gconstpointer a, gconstpointer b) +{ + guint one = kz_bookmark_get_last_modified((KzBookmark*)a); + guint two = kz_bookmark_get_last_modified((KzBookmark*)b); + return two - one; +} + + +void +kz_bookmark_folder_sort (KzBookmarkFolder *folder, const gchar *type) +{ + KzBookmarkFolderPrivate *priv = KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder); + + g_return_if_fail(KZ_IS_BOOKMARK_FOLDER(folder)); + + if (!type) return; + + /* FIXME! use hash table */ + priv->children = g_list_sort(priv->children, compare_func); + + g_signal_emit(folder, signals[CHILDREN_REORDERED_SIGNAL], 0); +} + + +void +kz_bookmark_folder_register_sort_func (const gchar *type, GCompareFunc *func) +{ + g_warning("kz_bookmark_folder_register_sort_func() is not implemented yet."); +} + + +KzBookmark * +kz_bookmark_folder_find_bookmark_from_uri (KzBookmarkFolder *folder, const gchar *key_uri) +{ + GList *node; + KzBookmarkFolderPrivate *priv = KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder); + + g_return_val_if_fail(KZ_IS_BOOKMARK_FOLDER(folder), NULL); + + /* FIXME! Use hash? */ + for (node = priv->children; node; node = g_list_next(node)) + { + KzBookmark *child = node->data; + const gchar *uri = kz_bookmark_get_link(child); + if (uri && key_uri && !g_strcmp(uri, key_uri)) + return child; + + if (!KZ_IS_BOOKMARK_FOLDER(child)) + continue; + + child = kz_bookmark_folder_find_bookmark_from_uri(KZ_BOOKMARK_FOLDER(child), + key_uri); + if (child) + return child; + } + + return NULL; +} + +void +kz_bookmark_folder_foreach_child (KzBookmarkFolder*folder, + GFunc func, + gpointer user_data) +{ + KzBookmarkFolderPrivate *priv = KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder); + + if (!priv->children) + return; + + g_list_foreach(priv->children, func, user_data); +} + +KzBookmark * +kz_bookmark_folder_get_nth_child (KzBookmarkFolder *folder, gint index) +{ + KzBookmarkFolderPrivate *priv = KZ_BOOKMARK_FOLDER_GET_PRIVATE(folder); + + if (!priv->children) + return NULL; + + if (g_list_length(priv->children) < index) + return NULL; + + return KZ_BOOKMARK(g_list_nth_data(priv->children, index)); +} + Added: kazehakase/trunk/src/bookmarks/kz-bookmark-folder.h =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark-folder.h (rev 0) +++ kazehakase/trunk/src/bookmarks/kz-bookmark-folder.h 2009-02-12 03:06:11 UTC (rev 3627) @@ -0,0 +1,120 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* + * Copyright (C) 2003 Hiroyuki Ikezoe + * Copyright (C) 2003 Takuro Ashie + * + * This program 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 2, or (at your option) + * any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#ifndef __KZ_BOOKMARK_FOLDER_H__ +#define __KZ_BOOKMARK_FOLDER_H__ + +#include "kz-bookmark.h" + +G_BEGIN_DECLS + +#define KZ_TYPE_BOOKMARK_FOLDER (kz_bookmark_folder_get_type ()) +#define KZ_BOOKMARK_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KZ_TYPE_BOOKMARK_FOLDER, KzBookmarkFolder)) +#define KZ_BOOKMARK_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KZ_TYPE_BOOKMARK_FOLDER, KzBookmarkFolderClass)) +#define KZ_IS_BOOKMARK_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KZ_TYPE_BOOKMARK_FOLDER)) +#define KZ_IS_BOOKMARK_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KZ_TYPE_BOOKMARK_FOLDER)) +#define KZ_BOOKMARK_FOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KZ_TYPE_BOOKMARK_FOLDER, KzBookmarkFolderClass)) + +typedef struct _KzBookmarkFolder KzBookmarkFolder; +typedef struct _KzBookmarkFolderClass KzBookmarkFolderClass; + +#define KZ_BOOKMARK_FOLDER_SORT_LAST_MODIFIED "last-modified" + +struct _KzBookmarkFolder +{ + KzBookmark parent; +}; + +struct _KzBookmarkFolderClass +{ + KzBookmarkClass parent_class; + + /* -- signals -- */ + void (*insert_child) (KzBookmarkFolder *folder, + KzBookmark *child, + KzBookmark *sibling); + void (*remove_child) (KzBookmarkFolder *folder, + KzBookmark *child); + void (*move_child) (KzBookmarkFolder *folder, + KzBookmarkFolder *parent, + KzBookmark *sibling); + void (*children_reordered) (KzBookmarkFolder *boomark); + + GList *(*get_children) (KzBookmarkFolder *boomark); + gboolean (*has_children) (KzBookmarkFolder *boomark); +}; + +/* GType */ +GType kz_bookmark_folder_get_type (void) G_GNUC_CONST; + +/* boomark item creating functions */ +KzBookmark *kz_bookmark_folder_new (void); + +gboolean kz_bookmark_folder_is_editable (KzBookmarkFolder *folder); + +/* folder interface */ +gboolean kz_bookmark_folder_is_pure_folder (KzBookmarkFolder *folder); +gboolean kz_bookmark_folder_get_folded (KzBookmarkFolder *folder); +void kz_bookmark_folder_set_folded (KzBookmarkFolder *folder, + gboolean folded); +void kz_bookmark_folder_insert_before (KzBookmarkFolder *folder, + KzBookmark *child, + KzBookmark *sibling); +void kz_bookmark_folder_append (KzBookmarkFolder *folder, + KzBookmark *child); +void kz_bookmark_folder_prepend (KzBookmarkFolder *folder, + KzBookmark *child); +void kz_bookmark_folder_remove (KzBookmarkFolder *folder, + KzBookmark *child); +void kz_bookmark_folder_remove_all (KzBookmarkFolder *folder); +GList *kz_bookmark_folder_get_children (KzBookmarkFolder *folder); +gboolean kz_bookmark_folder_has_children (KzBookmarkFolder *folder); +void kz_bookmark_folder_sort (KzBookmarkFolder *folder, + const gchar *type); +guint kz_bookmark_folder_get_current_position (KzBookmarkFolder *folder); +void kz_bookmark_folder_set_current_position (KzBookmarkFolder *folder, + guint pos); +gboolean kz_bookmark_folder_get_lock (KzBookmarkFolder *folder); +void kz_bookmark_folder_set_lock (KzBookmarkFolder *folder, + gboolean lock); +gboolean kz_bookmark_folder_get_auto_refresh (KzBookmarkFolder *folder); +void kz_bookmark_folder_set_auto_refresh (KzBookmarkFolder *folder, + gboolean auto_refresh); +gboolean kz_bookmark_folder_get_javascript (KzBookmarkFolder *folder); +void kz_bookmark_folder_set_javascript (KzBookmarkFolder *folder, + gboolean javascript); + +void kz_bookmark_folder_register_sort_func (const gchar *type, + GCompareFunc *func); + +KzBookmark *kz_bookmark_folder_get_current_bookmark (KzBookmarkFolder *folder); +KzBookmark *kz_bookmark_folder_find_bookmark_from_uri + (KzBookmarkFolder *folder, + const gchar *key_uri); +void kz_bookmark_folder_foreach_child (KzBookmarkFolder *folder, + GFunc func, + gpointer user_data); +KzBookmark *kz_bookmark_folder_get_nth_child (KzBookmarkFolder *folder, + gint index); +G_END_DECLS + +#endif /* __KZ_BOOKMARK_FOLDER_H__ */ Modified: kazehakase/trunk/src/bookmarks/kz-bookmark-item.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark-item.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-bookmark-item.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -690,7 +690,7 @@ bookmark = KZ_BOOKMARK_ITEM(src_widget)->bookmark; g_object_ref(bookmark); parent = kz_bookmark_get_parent(bookmark); - kz_bookmark_remove(parent, bookmark); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(parent), bookmark); moved = TRUE; break; case TARGET_NETSCAPE_URL: @@ -703,7 +703,7 @@ if (bookmark) { - kz_bookmark_append(item->bookmark, bookmark); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(item->bookmark), bookmark); if (KZ_IS_BOOKMARK_FILE(item->bookmark)) file = item->bookmark; else Modified: kazehakase/trunk/src/bookmarks/kz-bookmark-menu-item-list.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark-menu-item-list.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-bookmark-menu-item-list.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -281,7 +281,7 @@ if (sibling) { - children = kz_bookmark_get_children(folder); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(folder)); index = g_list_index(children, sibling); g_list_free(children); } @@ -318,7 +318,7 @@ g_return_if_fail(KZ_IS_BOOKMARK(child)); - children = kz_bookmark_get_children(folder); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(folder)); index = g_list_index(children, child); g_list_free(children); Modified: kazehakase/trunk/src/bookmarks/kz-bookmark-menu.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark-menu.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-bookmark-menu.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -76,7 +76,7 @@ kz_bookmark_menu_item_list_new(shell, kz, folder); /* children */ - children = kz_bookmark_get_children(folder); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(folder)); for (node = children; node; node = g_list_next(node)) { KzBookmark *child = node->data; Modified: kazehakase/trunk/src/bookmarks/kz-bookmark-tab-menu.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark-tab-menu.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-bookmark-tab-menu.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -68,7 +68,7 @@ g_return_val_if_fail(kz_bookmark_is_folder(bookmark), NULL); g_return_val_if_fail(KZ_IS_WINDOW(kz), NULL); - current_page = kz_bookmark_get_current_bookmark(bookmark); + current_page = kz_bookmark_folder_get_current_bookmark(KZ_BOOKMARK_FOLDER(bookmark)); if (!KZ_IS_BOOKMARK(current_page)) return NULL; title = kz_bookmark_get_title(current_page); @@ -132,7 +132,7 @@ disconnect_menu_signals(prev_folder, shell); } - children = kz_bookmark_get_children(folder); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(folder)); /* empty label */ { @@ -367,7 +367,7 @@ g_return_if_fail(node); gtk_widget_destroy(node->data); - if (kz_bookmark_has_children(item)) return; + if (kz_bookmark_folder_has_children(KZ_BOOKMARK_FOLDER(item))) return; empty_label = g_object_get_data(G_OBJECT(shell), KZ_BOOKMARK_TAB_MENU_EMPTY_KEY); @@ -522,6 +522,6 @@ kz_tab_label_set_history(KZ_TAB_LABEL(kztab), item); /* FIXME! should use parent bookmark */ - kz_bookmark_remove(kz->closed_tabs, item); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(kz->closed_tabs), item); } Modified: kazehakase/trunk/src/bookmarks/kz-bookmark.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-bookmark.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -30,20 +30,11 @@ #include "kz-marshalers.h" #include "utils.h" #include "kz-bookmark-file.h" +#include "kz-bookmark-folder.h" #include "kz-bookmark-separator.h" #include "kz-bookmarks-enum-types.h" enum { - INSERT_CHILD_SIGNAL, - REMOVE_CHILD_SIGNAL, - MOVE_CHILD_SIGNAL, - CHILDREN_REORDERED_SIGNAL, - GET_CHILDREN_SIGNAL, - HAS_CHILDREN_SIGNAL, - LAST_SIGNAL -}; - -enum { PROP_0, PROP_TYPE, PROP_TITLE, @@ -54,11 +45,7 @@ PROP_LAST_MODIFIED, PROP_LAST_VISITED, PROP_ADDED_TIME, - PROP_INTERVAL, - PROP_CURRENT_POS, - PROP_LOCK, - PROP_AUTO_REFRESH, - PROP_JAVASCRIPT + PROP_INTERVAL }; @@ -72,16 +59,6 @@ GValue *value, GParamSpec *pspec); -static void kz_bookmark_real_insert_child (KzBookmark *bookmark, - KzBookmark *child, - KzBookmark *sibling); -static void kz_bookmark_real_remove_child (KzBookmark *bookmark, - KzBookmark *child); -static GList *kz_bookmark_real_get_children (KzBookmark *bookmark); -static gboolean kz_bookmark_real_has_children (KzBookmark *bookmark); - -static gint kz_bookmark_signals[LAST_SIGNAL] = {0}; - static GQuark id_quark = 0; static GQuark title_quark = 0; static GQuark doc_title_quark = 0; @@ -91,11 +68,6 @@ static GQuark last_visited_quark = 0; static GQuark added_time_quark = 0; static GQuark parent_quark = 0; -static GQuark children_quark = 0; -static GQuark current_pos_quark = 0; -static GQuark lock_quark = 0; -static GQuark auto_refresh_quark = 0; -static GQuark javascript_quark = 0; G_DEFINE_TYPE(KzBookmark, kz_bookmark, G_TYPE_OBJECT) @@ -111,13 +83,6 @@ object_class->set_property = set_property; object_class->get_property = get_property; - klass->insert_child = kz_bookmark_real_insert_child; - klass->remove_child = kz_bookmark_real_remove_child; - klass->move_child = NULL; /* kz_bookmark_real_move_child; */ - klass->children_reordered = NULL; - klass->get_children = kz_bookmark_real_get_children; - klass->has_children = kz_bookmark_real_has_children; - g_object_class_install_property( object_class, PROP_TYPE, @@ -215,106 +180,7 @@ 0, G_PARAM_READWRITE)); - g_object_class_install_property( - object_class, - PROP_CURRENT_POS, - g_param_spec_uint( - "current", - _("Current Position"), - _("Current position in history"), - 0, - G_MAXUINT, - 0, - G_PARAM_READWRITE)); - g_object_class_install_property( - object_class, - PROP_LOCK, - g_param_spec_boolean( - "lock", - _("Lock state"), - _("Lock state for tab"), - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property( - object_class, - PROP_AUTO_REFRESH, - g_param_spec_boolean( - "auto-refresh", - _("Auto Refresh state"), - _("Auto Refresh state for tab"), - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property( - object_class, - PROP_JAVASCRIPT, - g_param_spec_boolean( - "javascript", - _("Javascript state"), - _("Javascript state for tab"), - FALSE, - G_PARAM_READWRITE)); - - kz_bookmark_signals[INSERT_CHILD_SIGNAL] - = g_signal_new ("insert-child", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (KzBookmarkClass, insert_child), - NULL, NULL, - _kz_marshal_VOID__OBJECT_OBJECT, - G_TYPE_NONE, 2, - KZ_TYPE_BOOKMARK, KZ_TYPE_BOOKMARK); - - kz_bookmark_signals[REMOVE_CHILD_SIGNAL] - = g_signal_new ("remove-child", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (KzBookmarkClass, remove_child), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - KZ_TYPE_BOOKMARK); - - kz_bookmark_signals[MOVE_CHILD_SIGNAL] - = g_signal_new ("move-child", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (KzBookmarkClass, move_child), - NULL, NULL, - _kz_marshal_VOID__OBJECT_OBJECT, - G_TYPE_NONE, 2, - KZ_TYPE_BOOKMARK, KZ_TYPE_BOOKMARK); - - kz_bookmark_signals[CHILDREN_REORDERED_SIGNAL] - = g_signal_new ("children-reordered", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (KzBookmarkClass, - children_reordered), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - kz_bookmark_signals[GET_CHILDREN_SIGNAL] - = g_signal_new ("get-children", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (KzBookmarkClass, get_children), - NULL, NULL, - _kz_marshal_POINTER__VOID, - G_TYPE_POINTER, 0); - - kz_bookmark_signals[HAS_CHILDREN_SIGNAL] - = g_signal_new ("has-children", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (KzBookmarkClass, has_children), - NULL, NULL, - _kz_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); - /* FIXME! add other properties */ /* * candidates: @@ -334,11 +200,6 @@ last_visited_quark = g_quark_from_string("KzBookmark::LastVisited"); added_time_quark = g_quark_from_string("KzBookmark::AddedTime"); parent_quark = g_quark_from_string("KzBookmark::Parent"); - children_quark = g_quark_from_string("KzBookmark::Children"); - current_pos_quark = g_quark_from_string("KzBookmark::Current"); - lock_quark = g_quark_from_string("KzBookmark::Lock"); - auto_refresh_quark = g_quark_from_string("KzBookmark::AutoRefresh"); - javascript_quark = g_quark_from_string("KzBookmark::Javascript"); } static void @@ -350,12 +211,6 @@ static void dispose (GObject *object) { - KzBookmark *bookmark; - - bookmark = KZ_BOOKMARK(object); - - kz_bookmark_remove_all(bookmark); - if (G_OBJECT_CLASS (kz_bookmark_parent_class)->dispose) G_OBJECT_CLASS (kz_bookmark_parent_class)->dispose(object); } @@ -385,7 +240,6 @@ kz_bookmark_set_document_title(bookmark, g_value_get_string(value)); break; case PROP_LINK: - g_return_if_fail(!kz_bookmark_is_pure_folder(bookmark)); g_return_if_fail(!kz_bookmark_is_separator(bookmark)); kz_bookmark_set_link(bookmark, g_value_get_string(value)); break; @@ -405,24 +259,6 @@ g_return_if_fail(!kz_bookmark_is_separator(bookmark)); kz_bookmark_set_added_time(bookmark ,g_value_get_uint(value)); break; - case PROP_CURRENT_POS: - g_return_if_fail(kz_bookmark_is_folder(bookmark)); - kz_bookmark_set_current(bookmark, g_value_get_uint(value)); - break; - case PROP_LOCK: - g_return_if_fail(kz_bookmark_is_folder(bookmark)); - kz_bookmark_set_lock(bookmark, g_value_get_boolean(value)); - break; - case PROP_AUTO_REFRESH: - g_return_if_fail(kz_bookmark_is_folder(bookmark)); - g_object_set_qdata(object, auto_refresh_quark, - GINT_TO_POINTER(g_value_get_boolean(value))); - break; - case PROP_JAVASCRIPT: - g_return_if_fail(kz_bookmark_is_folder(bookmark)); - g_object_set_qdata(object, javascript_quark, - GINT_TO_POINTER(g_value_get_boolean(value))); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -479,26 +315,6 @@ added_time_quark)); g_value_set_uint(value, time); break; - case PROP_CURRENT_POS: - time = GPOINTER_TO_UINT(g_object_get_qdata(object, - current_pos_quark)); - g_value_set_uint(value, time); - break; - case PROP_LOCK: - time = GPOINTER_TO_INT(g_object_get_qdata(object, - lock_quark)); - g_value_set_boolean(value, time); - break; - case PROP_AUTO_REFRESH: - time = GPOINTER_TO_INT(g_object_get_qdata(object, - auto_refresh_quark)); - g_value_set_boolean(value, time); - break; - case PROP_JAVASCRIPT: - time = GPOINTER_TO_INT(g_object_get_qdata(object, - javascript_quark)); - g_value_set_boolean(value, time); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -514,20 +330,7 @@ return bookmark; } - KzBookmark * -kz_bookmark_pure_folder_new (void) -{ - KzBookmark *bookmark; - - bookmark = g_object_new(KZ_TYPE_BOOKMARK, - "type", KZ_BOOKMARK_PURE_FOLDER, - NULL); - return bookmark; -} - - -KzBookmark * kz_bookmark_new_with_attrs (const gchar *title, const gchar *uri, const gchar *description) @@ -711,170 +514,23 @@ g_object_notify(G_OBJECT(bookmark), "added-time"); } -gboolean -kz_bookmark_is_folder(KzBookmark *bookmark) +KzBookmark * +kz_bookmark_get_parent (KzBookmark *bookmark) { - g_return_val_if_fail(KZ_IS_BOOKMARK(bookmark), FALSE); + g_return_val_if_fail(KZ_IS_BOOKMARK(bookmark), NULL); - return (KZ_IS_BOOKMARK_FILE(bookmark) || - bookmark->type == KZ_BOOKMARK_PURE_FOLDER); + return g_object_get_qdata(G_OBJECT(bookmark), parent_quark); } - -gboolean -kz_bookmark_is_pure_folder (KzBookmark *bookmark) -{ - g_return_val_if_fail(KZ_IS_BOOKMARK(bookmark), FALSE); - - return (bookmark->type == KZ_BOOKMARK_PURE_FOLDER); -} - - -gboolean -kz_bookmark_get_folded (KzBookmark *bookmark) -{ - g_return_val_if_fail(KZ_IS_BOOKMARK(bookmark), FALSE); - - if (!kz_bookmark_is_folder(bookmark)) return TRUE; - - return bookmark->flags & KZ_BOOKMARK_FOLDED_FLAG; -} - - void -kz_bookmark_set_folded (KzBookmark *bookmark, gboolean folded) +kz_bookmark_set_parent (KzBookmark *bookmark, KzBookmark *parent) { g_return_if_fail(KZ_IS_BOOKMARK(bookmark)); - if (folded) - { - bookmark->flags |= KZ_BOOKMARK_FOLDED_FLAG; - } - else - { - bookmark->flags &= ~KZ_BOOKMARK_FOLDED_FLAG; - } + g_object_set_qdata(G_OBJECT(bookmark), parent_quark, parent); } - -static void -kz_bookmark_real_insert_child (KzBookmark *bookmark, - KzBookmark *child, - KzBookmark *sibling) -{ - GList *list, *next = NULL; - - g_return_if_fail(KZ_IS_BOOKMARK(child)); - g_return_if_fail(!sibling || KZ_IS_BOOKMARK(sibling)); - g_return_if_fail(kz_bookmark_is_folder(bookmark)); - - list = g_object_get_qdata(G_OBJECT(bookmark), children_quark); - if (sibling) - next = g_list_find(list, sibling); - - g_object_ref(child); - list = g_list_insert_before(list, next, child); - g_object_set_qdata(G_OBJECT(bookmark), children_quark, list); - - g_object_set_qdata(G_OBJECT(child), parent_quark, bookmark); -} - - -void -kz_bookmark_insert_before (KzBookmark *bookmark, - KzBookmark *child, - KzBookmark *sibling) -{ - g_return_if_fail(KZ_IS_BOOKMARK(bookmark)); - - g_signal_emit(bookmark, - kz_bookmark_signals[INSERT_CHILD_SIGNAL], 0, - child, sibling); -} - - -void -kz_bookmark_append (KzBookmark *bookmark, KzBookmark *child) -{ - kz_bookmark_insert_before(bookmark, child, NULL); -} - - -void -kz_bookmark_prepend (KzBookmark *bookmark, KzBookmark *child) -{ - GList *list; - - g_return_if_fail(KZ_IS_BOOKMARK(bookmark)); - - list = g_object_get_qdata(G_OBJECT(bookmark), children_quark); - if (list) - kz_bookmark_insert_before(bookmark, child, list->data); - else - kz_bookmark_insert_before(bookmark, child, NULL); -} - - -static void -kz_bookmark_real_remove_child (KzBookmark *bookmark, KzBookmark *child) -{ - GList *list; - - g_return_if_fail(KZ_IS_BOOKMARK(bookmark)); - g_return_if_fail(KZ_IS_BOOKMARK(child)); - g_return_if_fail(kz_bookmark_is_folder(bookmark)); - - list = g_object_get_qdata(G_OBJECT(bookmark), children_quark); - if (!g_list_find(list, child)) return; - - list = g_list_remove(list, child); - g_object_set_qdata(G_OBJECT(bookmark), children_quark, list); - - g_object_set_qdata(G_OBJECT(child), parent_quark, NULL); - g_object_unref(child); -} - - -void -kz_bookmark_remove (KzBookmark *bookmark, KzBookmark *child) -{ - g_signal_emit(bookmark, - kz_bookmark_signals[REMOVE_CHILD_SIGNAL], 0, - child); -} - - -void -kz_bookmark_remove_all (KzBookmark *bookmark) -{ - GList *children, *node, *prev; - - children = g_object_get_qdata(G_OBJECT(bookmark), children_quark); - children = g_list_copy(children); - - node = g_list_last(children); - while (node) - { - KzBookmark *child = node->data; - prev = g_list_previous(node); - kz_bookmark_remove (bookmark, child); - node = prev; - } - - g_list_free(children); -} - - KzBookmark * -kz_bookmark_get_parent (KzBookmark *bookmark) -{ - g_return_val_if_fail(KZ_IS_BOOKMARK(bookmark), NULL); - - return g_object_get_qdata(G_OBJECT(bookmark), parent_quark); -} - - -KzBookmark * kz_bookmark_get_parent_file (KzBookmark *bookmark) { KzBookmark *parent = bookmark; @@ -891,67 +547,19 @@ return NULL; } - -static GList * -kz_bookmark_real_get_children (KzBookmark *bookmark) -{ - GList *list; - - list = g_object_get_qdata(G_OBJECT(bookmark), children_quark); - - return list ? g_list_copy(list) : NULL; -} - -GList * -kz_bookmark_get_children (KzBookmark *bookmark) -{ - GList *result; - - g_return_val_if_fail(KZ_IS_BOOKMARK(bookmark), NULL); - - g_signal_emit(bookmark, - kz_bookmark_signals[GET_CHILDREN_SIGNAL], 0, - &result); - return result; -} - - -static gboolean -kz_bookmark_real_has_children (KzBookmark *bookmark) -{ - GList *list; - - list = g_object_get_qdata(G_OBJECT(bookmark), children_quark); - - return (list != NULL); -} - -gboolean -kz_bookmark_has_children (KzBookmark *bookmark) -{ - gboolean result; - - g_return_val_if_fail(KZ_IS_BOOKMARK(bookmark), FALSE); - - g_signal_emit(bookmark, - kz_bookmark_signals[HAS_CHILDREN_SIGNAL], 0, - &result); - return result; -} - KzBookmark * kz_bookmark_next (KzBookmark *bookmark) { KzBookmark *parent; - GList *list, *node; + GList *children, *node; g_return_val_if_fail(KZ_IS_BOOKMARK(bookmark), NULL); parent = kz_bookmark_get_parent(bookmark); if (!parent) return NULL; - list = g_object_get_qdata(G_OBJECT(parent), children_quark); - node = g_list_find(list, bookmark); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(parent)); + node = g_list_find(children, bookmark); if (node && (node = g_list_next(node))) return node->data; @@ -963,189 +571,18 @@ kz_bookmark_prev (KzBookmark *bookmark) { KzBookmark *parent; - GList *list, *node; + GList *children, *node; g_return_val_if_fail(KZ_IS_BOOKMARK(bookmark), NULL); parent = kz_bookmark_get_parent(bookmark); if (!parent) return NULL; - list = g_object_get_qdata(G_OBJECT(parent), children_quark); - node = g_list_find(list, bookmark); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(parent)); + node = g_list_find(children, bookmark); if (node && (node = g_list_previous(node))) return node->data; return NULL; } -/* return current activate tab position */ -guint -kz_bookmark_get_current (KzBookmark *bookmark) -{ - if (!kz_bookmark_is_folder(bookmark)) return 0; - - return GPOINTER_TO_UINT(g_object_get_qdata(G_OBJECT(bookmark), - current_pos_quark)); -} -void -kz_bookmark_set_current (KzBookmark *bookmark, guint pos) -{ - if (!kz_bookmark_is_folder(bookmark)) return; - - g_object_set_qdata(G_OBJECT(bookmark), current_pos_quark, - GUINT_TO_POINTER(pos)); - g_object_notify(G_OBJECT(bookmark), "current"); -} - -KzBookmark * -kz_bookmark_get_current_bookmark (KzBookmark *bookmark) -{ - GList *children; - gpointer *current_bookmark; - - if (!kz_bookmark_is_folder(bookmark)) - return NULL; - - children = g_object_get_qdata(G_OBJECT(bookmark), children_quark); - current_bookmark = g_list_nth_data(children, kz_bookmark_get_current(bookmark)); - - return current_bookmark ? KZ_BOOKMARK(current_bookmark) : NULL; -} - -gboolean -kz_bookmark_get_lock (KzBookmark *bookmark) -{ - if (!kz_bookmark_is_folder(bookmark)) return FALSE; - - return GPOINTER_TO_INT(g_object_get_qdata(G_OBJECT(bookmark), - lock_quark)); -} - -void -kz_bookmark_set_lock (KzBookmark *bookmark, - gboolean lock) -{ - if (!kz_bookmark_is_folder(bookmark)) return; - - g_object_set_qdata(G_OBJECT(bookmark), lock_quark, - GINT_TO_POINTER(lock)); - g_object_notify(G_OBJECT(bookmark), "lock"); -} - -gboolean -kz_bookmark_get_auto_refresh (KzBookmark *bookmark) -{ - if (!kz_bookmark_is_folder(bookmark)) return FALSE; - - return GPOINTER_TO_INT(g_object_get_qdata(G_OBJECT(bookmark), - auto_refresh_quark)); -} - -void -kz_bookmark_set_auto_refresh (KzBookmark *bookmark, - gboolean auto_refresh) -{ - if (!kz_bookmark_is_folder(bookmark)) return; - - g_object_set_qdata(G_OBJECT(bookmark), auto_refresh_quark, - GINT_TO_POINTER(auto_refresh)); - g_object_notify(G_OBJECT(bookmark), "auto-refresh"); -} - -gboolean -kz_bookmark_get_javascript (KzBookmark *bookmark) -{ - if (!kz_bookmark_is_folder(bookmark)) return FALSE; - - return GPOINTER_TO_INT(g_object_get_qdata(G_OBJECT(bookmark), - javascript_quark)); -} - -void -kz_bookmark_set_javascript (KzBookmark *bookmark, - gboolean javascript) -{ - if (!kz_bookmark_is_folder(bookmark)) return; - - g_object_set_qdata(G_OBJECT(bookmark), javascript_quark, - GINT_TO_POINTER(javascript)); - g_object_notify(G_OBJECT(bookmark), "javascript"); -} - -static gint -compare_func (gconstpointer a, gconstpointer b) -{ - guint one = kz_bookmark_get_last_modified((KzBookmark*)a); - guint two = kz_bookmark_get_last_modified((KzBookmark*)b); - return two - one; -} - - -void -kz_bookmark_sort (KzBookmark *bookmark, const gchar *type) -{ - GList *children; - - g_return_if_fail(KZ_IS_BOOKMARK(bookmark)); - g_return_if_fail(kz_bookmark_is_folder(bookmark)); - - if (!type) return; - - children = g_object_get_qdata(G_OBJECT(bookmark), children_quark); - - /* FIXME! use hash table */ - if (!strcmp(type, KZ_BOOKMARK_SORT_LAST_MODIFIED)) - children = g_list_sort(children, compare_func); - else - return; - - g_object_set_qdata(G_OBJECT(bookmark), children_quark, children); - - g_signal_emit(bookmark, - kz_bookmark_signals[CHILDREN_REORDERED_SIGNAL], 0); -} - - -void -kz_bookmark_register_sort_func (const gchar *type, GCompareFunc *func) -{ - g_warning("kz_bookmark_register_sort_func() is not implemented yet."); -} - - -KzBookmark * -kz_bookmark_find_bookmark_from_uri (KzBookmark *folder, const gchar *key_uri) -{ - GList *children, *node; - KzBookmark *bookmark = NULL; - - children = kz_bookmark_get_children(folder); - - /* FIXME! Use hash? */ - for (node = children; node; node = g_list_next(node)) - { - KzBookmark *child = node->data; - const gchar *uri = kz_bookmark_get_link(child); - if (uri && key_uri && !g_strcmp(uri, key_uri)) - { - bookmark = child; - break; - } - - if (kz_bookmark_is_folder(child)) - { - KzBookmark *find; - find = kz_bookmark_find_bookmark_from_uri(child, - key_uri); - if (find) - { - bookmark = find; - break; - } - } - } - g_list_free(children); - - return bookmark; -} - Modified: kazehakase/trunk/src/bookmarks/kz-bookmark.h =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark.h 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-bookmark.h 2009-02-12 03:06:11 UTC (rev 3627) @@ -40,40 +40,18 @@ typedef enum { KZ_BOOKMARK_NORMAL, - KZ_BOOKMARK_PURE_FOLDER, KZ_BOOKMARK_N_TYPES } KzBookmarkType; -typedef enum { - KZ_BOOKMARK_FOLDED_FLAG = 1 << 0 -} KzBookmarkFlag; - -#define KZ_BOOKMARK_SORT_LAST_MODIFIED "last-modified" - struct _KzBookmark { GObject parent; KzBookmarkType type; - KzBookmarkFlag flags; }; struct _KzBookmarkClass { GObjectClass parent_class; - - /* -- signals -- */ - void (*insert_child) (KzBookmark *bookmark, - KzBookmark *child, - KzBookmark *sibling); - void (*remove_child) (KzBookmark *bookmark, - KzBookmark *child); - void (*move_child) (KzBookmark *bookmark, - KzBookmark *parent, - KzBookmark *sibling); - void (*children_reordered) (KzBookmark *boomark); - - GList *(*get_children) (KzBookmark *boomark); - gboolean (*has_children) (KzBookmark *boomark); }; @@ -85,7 +63,6 @@ KzBookmark *kz_bookmark_new_with_attrs (const gchar *title, const gchar *uri, const gchar *description); -KzBookmark *kz_bookmark_pure_folder_new (void); /* set/get properties */ /* * "ID" is md5sum of URI of the parent bookmark file + ":" + ID @@ -122,48 +99,15 @@ #define kz_bookmark_is_separator KZ_IS_BOOKMARK_SEPARATOR /* folder interface */ -gboolean kz_bookmark_is_folder (KzBookmark *bookmark); -gboolean kz_bookmark_is_pure_folder (KzBookmark *bookmark); -gboolean kz_bookmark_get_folded (KzBookmark *bookmark); -void kz_bookmark_set_folded (KzBookmark *bookmark, - gboolean folded); -void kz_bookmark_insert_before (KzBookmark *bookmark, - KzBookmark *child, - KzBookmark *sibling); -void kz_bookmark_append (KzBookmark *bookmark, - KzBookmark *child); -void kz_bookmark_prepend (KzBookmark *bookmark, - KzBookmark *child); -void kz_bookmark_remove (KzBookmark *bookmark, - KzBookmark *child); -void kz_bookmark_remove_all (KzBookmark *bookmark); -KzBookmark *kz_bookmark_get_parent (KzBookmark *bookmark); +#define kz_bookmark_is_folder KZ_IS_BOOKMARK_FOLDER +KzBookmark* + kz_bookmark_get_parent (KzBookmark *bookmark); +void kz_bookmark_set_parent (KzBookmark *bookmark, + KzBookmark *parent); KzBookmark *kz_bookmark_get_parent_file (KzBookmark *bookmark); -GList *kz_bookmark_get_children (KzBookmark *bookmark); -gboolean kz_bookmark_has_children (KzBookmark *bookmark); KzBookmark *kz_bookmark_next (KzBookmark *bookmark); KzBookmark *kz_bookmark_prev (KzBookmark *bookmark); -void kz_bookmark_sort (KzBookmark *bookmark, - const gchar *type); -guint kz_bookmark_get_current (KzBookmark *bookmark); -void kz_bookmark_set_current (KzBookmark *bookmark, - guint pos); -gboolean kz_bookmark_get_lock (KzBookmark *bookmark); -void kz_bookmark_set_lock (KzBookmark *bookmark, - gboolean lock); -gboolean kz_bookmark_get_auto_refresh (KzBookmark *bookmark); -void kz_bookmark_set_auto_refresh (KzBookmark *bookmark, - gboolean auto_refresh); -gboolean kz_bookmark_get_javascript (KzBookmark *bookmark); -void kz_bookmark_set_javascript (KzBookmark *bookmark, - gboolean javascript); -void kz_bookmark_register_sort_func (const gchar *type, - GCompareFunc *func); - -KzBookmark *kz_bookmark_get_current_bookmark (KzBookmark *bookmark); -KzBookmark *kz_bookmark_find_bookmark_from_uri (KzBookmark *bookmark, - const gchar *key_uri); G_END_DECLS #endif /* __KZ_BOOKMARK_H__ */ Modified: kazehakase/trunk/src/bookmarks/kz-bookmarks-view.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmarks-view.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-bookmarks-view.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -62,10 +62,10 @@ static void dispose (GObject *object); -static void connect_bookmark_signals (KzBookmarksView *view, - KzBookmark *bookmark); -static void disconnect_bookmark_signals (KzBookmarksView *view, - KzBookmark *bookmark); +static void connect_bookmark_signals (KzBookmark *bookmark, + KzBookmarksView *view); +static void disconnect_bookmark_signals (KzBookmark *bookmark, + KzBookmarksView *view); static GtkTreePath *find_row (GtkTreeModel *model, KzBookmark *bookmark); @@ -148,7 +148,7 @@ if (view->root_folder) { - disconnect_bookmark_signals(view, view->root_folder); + disconnect_bookmark_signals(KZ_BOOKMARK(view->root_folder), view); g_object_unref(view->root_folder); view->root_folder = NULL; } @@ -262,7 +262,7 @@ if (view->root_folder) { - disconnect_bookmark_signals(view, view->root_folder); + disconnect_bookmark_signals(KZ_BOOKMARK(view->root_folder), view); g_object_unref(view->root_folder); view->root_folder = NULL; } @@ -276,7 +276,7 @@ view->root_folder = top_folder; g_object_ref(view->root_folder); - connect_bookmark_signals(view, view->root_folder); + connect_bookmark_signals(KZ_BOOKMARK(view->root_folder), view); if (include_top) { @@ -287,7 +287,7 @@ { GList *children, *node; - children = kz_bookmark_get_children(top_folder); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(top_folder)); for (node = children; node; node = g_list_next(node)) { insert_bookmark(view, folder_only, @@ -392,7 +392,7 @@ if (!sibling) return NULL; - children = kz_bookmark_get_children(parent); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(parent)); node = g_list_find(children, sibling); g_return_val_if_fail(node, NULL); @@ -563,8 +563,8 @@ title_is_editable = FALSE; location_is_editable = FALSE; } - else if (!KZ_IS_BOOKMARK_FILE(bookmark) && - kz_bookmark_is_pure_folder(bookmark)) + else if (KZ_IS_BOOKMARK_FOLDER(bookmark) && + !KZ_IS_BOOKMARK_FILE(bookmark)) { location_is_editable = FALSE; } @@ -596,7 +596,7 @@ { GList *children, *node; - children = kz_bookmark_get_children(bookmark); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(bookmark)); for (node = children; node; node = g_list_next(node)) { if (!KZ_IS_BOOKMARK(node->data)) @@ -611,7 +611,8 @@ } /* expand */ - if (!kz_bookmark_get_folded(bookmark)) + if (KZ_IS_BOOKMARK_FOLDER(bookmark) && + !kz_bookmark_folder_get_folded(KZ_BOOKMARK_FOLDER(bookmark))) { path = gtk_tree_model_get_path(model, &iter); gtk_tree_view_expand_row(GTK_TREE_VIEW(view), path, FALSE); @@ -796,7 +797,7 @@ return; priv = KZ_BOOKMARKS_VIEW_GET_PRIVATE (view); - connect_bookmark_signals (view, child); + connect_bookmark_signals (KZ_BOOKMARK(child), view); if (!priv->folder_only || kz_bookmark_is_folder(child)) insert_bookmark(view, priv->folder_only, @@ -808,7 +809,7 @@ cb_bookmark_remove_child (KzBookmark *bookmark, KzBookmark *child, KzBookmarksView *view) { - disconnect_bookmark_signals (view, child); + disconnect_bookmark_signals(KZ_BOOKMARK(child), view); /* set selection */ ensure_cursor(view, child); @@ -831,53 +832,48 @@ static void -connect_bookmark_signals (KzBookmarksView *view, - KzBookmark *bookmark) +connect_bookmark_signals (KzBookmark *bookmark, + KzBookmarksView *view) { - GList *children, *node; - g_return_if_fail(KZ_IS_BOOKMARK(bookmark)); - g_signal_connect_after(bookmark, "insert-child", - G_CALLBACK(cb_bookmark_insert_child), view); - g_signal_connect(bookmark, "remove-child", - G_CALLBACK(cb_bookmark_remove_child), view); g_signal_connect(bookmark, "notify", G_CALLBACK(cb_bookmark_notify), view); if (!kz_bookmark_is_folder(bookmark)) return; - children = kz_bookmark_get_children(bookmark); - for (node = children; node; node = g_list_next(node)) - connect_bookmark_signals (view, node->data); - g_list_free(children); + g_signal_connect_after(bookmark, "insert-child", + G_CALLBACK(cb_bookmark_insert_child), view); + g_signal_connect(bookmark, "remove-child", + G_CALLBACK(cb_bookmark_remove_child), view); + + kz_bookmark_folder_foreach_child(KZ_BOOKMARK_FOLDER(bookmark), + (GFunc)connect_bookmark_signals, + view); } static void -disconnect_bookmark_signals (KzBookmarksView *view, - KzBookmark *bookmark) +disconnect_bookmark_signals (KzBookmark *bookmark, + KzBookmarksView *view) { - GList *children, *node; - g_return_if_fail(KZ_IS_BOOKMARK(bookmark)); g_signal_handlers_disconnect_by_func (bookmark, - G_CALLBACK(cb_bookmark_insert_child), view); - g_signal_handlers_disconnect_by_func - (bookmark, - G_CALLBACK(cb_bookmark_remove_child), view); - g_signal_handlers_disconnect_by_func - (bookmark, G_CALLBACK(cb_bookmark_notify), view); if (!kz_bookmark_is_folder(bookmark)) return; - children = kz_bookmark_get_children(bookmark); - for (node = children; node; node = g_list_next(node)) - disconnect_bookmark_signals (view, node->data); - g_list_free(children); + g_signal_handlers_disconnect_by_func + (bookmark, + G_CALLBACK(cb_bookmark_insert_child), view); + g_signal_handlers_disconnect_by_func + (bookmark, + G_CALLBACK(cb_bookmark_remove_child), view); + kz_bookmark_folder_foreach_child(KZ_BOOKMARK_FOLDER(bookmark), + (GFunc)disconnect_bookmark_signals, + view); } @@ -1081,7 +1077,7 @@ parent = kz_bookmark_get_parent(src); if (!parent) goto ERROR; g_object_ref(src); - kz_bookmark_remove(parent, src); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(parent), src); if (KZ_IS_BOOKMARK_FILE(parent)) file = parent; @@ -1112,7 +1108,7 @@ { GList *children, *node; - children = kz_bookmark_get_children(parent); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(parent)); node = g_list_find(children, dest); node = g_list_next(node); if (node) @@ -1125,7 +1121,7 @@ if (!parent) goto ERROR; - kz_bookmark_insert_before(parent, src, dest); + kz_bookmark_folder_insert_before(KZ_BOOKMARK_FOLDER(parent), src, dest); if (KZ_IS_BOOKMARK_FILE(parent)) file = parent; Modified: kazehakase/trunk/src/bookmarks/kz-hinadi.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-hinadi.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-hinadi.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -26,7 +26,9 @@ #include "kz-hinadi.h" +#include "kz-bookmark-folder.h" + static gboolean kz_hinadi_is_supported (KzBookmarkFile *bookmark, const gchar *buf); static gboolean kz_hinadi_parse_from_string (KzBookmarkFile *rbookmark, @@ -172,7 +174,7 @@ element_number++; } g_strfreev(elements); - kz_bookmark_append(KZ_BOOKMARK(bookmark), item); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(bookmark), item); g_object_unref(item); line_number++; } @@ -180,8 +182,8 @@ g_strfreev(lines); /* sorting */ - kz_bookmark_sort(KZ_BOOKMARK(bookmark), - KZ_BOOKMARK_SORT_LAST_MODIFIED); + kz_bookmark_folder_sort(KZ_BOOKMARK_FOLDER(bookmark), + KZ_BOOKMARK_FOLDER_SORT_LAST_MODIFIED); return TRUE; } Modified: kazehakase/trunk/src/bookmarks/kz-history.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-history.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-history.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -42,7 +42,6 @@ kz_history_new (const gchar *file) { return g_object_new(KZ_TYPE_HISTORY, - "type", KZ_BOOKMARK_PURE_FOLDER, "location", file, "title", _("History"), "file-type", "XBEL", Modified: kazehakase/trunk/src/bookmarks/kz-lirs.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-lirs.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-lirs.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -23,6 +23,7 @@ #include <time.h> #include "kz-lirs.h" +#include "kz-bookmark-folder.h" static gboolean kz_lirs_is_supported (KzBookmarkFile *bookmark, const gchar *buf); @@ -181,7 +182,7 @@ kz_bookmark_set_link(KZ_BOOKMARK(bookmark), elements[8]); g_strfreev(elements); - kz_bookmark_append(KZ_BOOKMARK(bookmark), item); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(bookmark), item); g_object_unref(item); line_number++; @@ -190,8 +191,8 @@ g_strfreev(lines); /* sorting */ - kz_bookmark_sort(KZ_BOOKMARK(bookmark), - KZ_BOOKMARK_SORT_LAST_MODIFIED); + kz_bookmark_folder_sort(KZ_BOOKMARK_FOLDER(bookmark), + KZ_BOOKMARK_FOLDER_SORT_LAST_MODIFIED); return TRUE; } Modified: kazehakase/trunk/src/bookmarks/kz-nsbookmark.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-nsbookmark.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-nsbookmark.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -113,7 +113,7 @@ if (!strncasecmp(pos, "<H3", 3)) { gchar *folder_title; - KzBookmark *folder = kz_bookmark_pure_folder_new(); + KzBookmark *folder = kz_bookmark_folder_new(); /* folder title */ folder_title = xml_get_content(pos); @@ -125,7 +125,7 @@ pos += 3; pos = kz_nsbookmark_parse_bookmark(folder, pos); - kz_bookmark_append(bookmark, folder); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(bookmark), folder); g_object_unref(folder); } else if (!strncasecmp(pos, "<A HREF=", 8)) @@ -145,7 +145,7 @@ g_free(title); } - kz_bookmark_append(bookmark, child); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(bookmark), child); g_object_unref(child); } else if (!strncasecmp(pos, "<DL>", 4)) @@ -157,7 +157,7 @@ /* separator */ KzBookmark *separator = kz_bookmark_separator_new(); - kz_bookmark_append(bookmark, separator); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(bookmark), separator); g_object_unref(separator); } else if (!strncasecmp(pos, "</DL>", 4)) Modified: kazehakase/trunk/src/bookmarks/kz-proxy-folder.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-proxy-folder.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-proxy-folder.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -18,7 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Id$ */ #include "kz-proxy-folder.h" @@ -28,14 +27,14 @@ typedef struct _KzProxyFolderPriv KzProxyFolderPriv; struct _KzProxyFolderPriv { - KzBookmark *bookmark; + KzBookmarkFolder *folder; }; #define KZ_PROXY_FOLDER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), KZ_TYPE_PROXY_FOLDER, KzProxyFolderPriv)) enum { PROP_0, - PROP_KZ_BOOKMARK + PROP_KZ_BOOKMARK_FOLDER }; static GObject *constructor (GType type, @@ -52,15 +51,15 @@ GValue *value, GParamSpec *pspec); -static void cb_folder_insert_child (KzBookmark *folder, - KzBookmark *child, - KzBookmark *sibling, +static void cb_folder_insert_child (KzBookmarkFolder *folder, + KzBookmark *child, + KzBookmark *sibling, KzProxyFolder *proxy); -static void cb_folder_remove_child (KzBookmark *folder, - KzBookmark *child, - KzProxyFolder *proxy); +static void cb_folder_remove_child (KzBookmarkFolder *folder, + KzBookmark *child, + KzProxyFolder *proxy); -G_DEFINE_TYPE(KzProxyFolder, kz_proxy_folder, KZ_TYPE_BOOKMARK) +G_DEFINE_TYPE(KzProxyFolder, kz_proxy_folder, KZ_TYPE_BOOKMARK_FOLDER) static void kz_proxy_folder_class_init (KzProxyFolderClass *klass) @@ -73,13 +72,14 @@ object_class->dispose = dispose; object_class->set_property = set_property; object_class->get_property = get_property; + g_object_class_install_property (object_class, - PROP_KZ_BOOKMARK, - g_param_spec_object ("kz-bookmark", - _("KzBookmark"), - _("The Bookmark object"), - KZ_TYPE_BOOKMARK, + PROP_KZ_BOOKMARK_FOLDER, + g_param_spec_object ("kz-bookmark-folder", + _("KzBookmarkFolder"), + _("The BookmarkFolder object"), + KZ_TYPE_BOOKMARK_FOLDER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_type_class_add_private (klass, sizeof(KzProxyFolderPriv)); @@ -91,17 +91,17 @@ { KzProxyFolderPriv *priv = KZ_PROXY_FOLDER_GET_PRIVATE(proxy); - priv->bookmark = NULL; + priv->folder = NULL; } static KzBookmark * -create_current_page_bookmark (KzBookmark *tab) +create_current_page_bookmark (KzBookmarkFolder *tab) { KzBookmark *current_page; KzBookmark *new; - current_page = kz_bookmark_get_current_bookmark(tab); + current_page = kz_bookmark_folder_get_current_bookmark(tab); new = kz_bookmark_new_with_attrs(current_page ? kz_bookmark_get_title(current_page) : "", current_page ? kz_bookmark_get_link(current_page) : "", @@ -111,18 +111,18 @@ static void -create_proxy_folder (KzProxyFolder *proxy, KzBookmark *tabs) +create_proxy_folder (KzProxyFolder *proxy, KzBookmarkFolder *tabs) { GList *children, *node; - children = kz_bookmark_get_children(tabs); + children = kz_bookmark_folder_get_children(tabs); for (node = children; node; node = g_list_next(node)) { KzBookmark *cur_page; - cur_page = create_current_page_bookmark(KZ_BOOKMARK(node->data)); + cur_page = create_current_page_bookmark(KZ_BOOKMARK_FOLDER(node->data)); - kz_bookmark_append(KZ_BOOKMARK(proxy), cur_page); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(proxy), cur_page); g_object_unref(cur_page); } @@ -137,20 +137,18 @@ { GObject *object; GObjectClass *klass = G_OBJECT_CLASS(kz_proxy_folder_parent_class); - KzProxyFolder *proxy; KzProxyFolderPriv *priv; object = klass->constructor(type, n_props, props); - proxy = KZ_PROXY_FOLDER(object); priv = KZ_PROXY_FOLDER_GET_PRIVATE(object); /* set signals */ - g_signal_connect(priv->bookmark, "insert-child", + g_signal_connect(priv->folder, "insert-child", G_CALLBACK(cb_folder_insert_child), - proxy); - g_signal_connect(priv->bookmark, "remove-child", + object); + g_signal_connect(priv->folder, "remove-child", G_CALLBACK(cb_folder_remove_child), - proxy); + object); return object; } @@ -159,22 +157,21 @@ static void dispose (GObject *object) { - KzProxyFolder *proxy = KZ_PROXY_FOLDER(object); KzProxyFolderPriv *priv = KZ_PROXY_FOLDER_GET_PRIVATE(object); - if (priv->bookmark) + if (priv->folder) { g_signal_handlers_disconnect_by_func - (priv->bookmark, + (priv->folder, G_CALLBACK(cb_folder_insert_child), - proxy); + object); g_signal_handlers_disconnect_by_func - (priv->bookmark, + (priv->folder, G_CALLBACK(cb_folder_remove_child), - proxy); - g_object_unref(priv->bookmark); + object); + g_object_unref(priv->folder); } - priv->bookmark = NULL; + priv->folder = NULL; if (G_OBJECT_CLASS (kz_proxy_folder_parent_class)->dispose) G_OBJECT_CLASS (kz_proxy_folder_parent_class)->dispose(object); @@ -191,8 +188,8 @@ switch (prop_id) { - case PROP_KZ_BOOKMARK: - priv->bookmark = g_object_ref(g_value_get_object(value)); + case PROP_KZ_BOOKMARK_FOLDER: + priv->folder = g_object_ref(g_value_get_object(value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -211,8 +208,8 @@ switch (prop_id) { - case PROP_KZ_BOOKMARK: - g_value_set_object(value, priv->bookmark); + case PROP_KZ_BOOKMARK_FOLDER: + g_value_set_object(value, priv->folder); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -222,61 +219,61 @@ KzBookmark * -kz_proxy_folder_new (KzBookmark *bookmark) +kz_proxy_folder_new (KzBookmarkFolder *folder) { - KzBookmark *proxy; - proxy = KZ_BOOKMARK(g_object_new(KZ_TYPE_PROXY_FOLDER, - "type", KZ_BOOKMARK_PURE_FOLDER, - "title", _("ProxyFolder"), - "kz-bookmark", bookmark, - NULL)); + KzProxyFolder *proxy; - create_proxy_folder(KZ_PROXY_FOLDER(proxy), bookmark); - return proxy; + proxy = g_object_new(KZ_TYPE_PROXY_FOLDER, + "title", _("ProxyFolder"), + "kz-bookmark-folder", folder, + NULL); + + create_proxy_folder(proxy, folder); + + return KZ_BOOKMARK(proxy); } static void -cb_folder_insert_child (KzBookmark *folder, +cb_folder_insert_child (KzBookmarkFolder *folder, KzBookmark *child, KzBookmark *sibling, KzProxyFolder *proxy) { KzBookmark *new; KzProxyFolderPriv *priv = KZ_PROXY_FOLDER_GET_PRIVATE(proxy); - new = create_current_page_bookmark(child); + new = create_current_page_bookmark(KZ_BOOKMARK_FOLDER(child)); if (sibling) { GList *list; gint index; - list = kz_bookmark_get_children(priv->bookmark); + list = kz_bookmark_folder_get_children(priv->folder); index = g_list_index(list, sibling); if (index >= 0) { GList *children; KzBookmark *sib; - children = kz_bookmark_get_children(KZ_BOOKMARK(proxy)); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(proxy)); sib = KZ_BOOKMARK(g_list_nth_data(children, index)); - kz_bookmark_insert_before(KZ_BOOKMARK(proxy), - new, - sib); + kz_bookmark_folder_insert_before(KZ_BOOKMARK_FOLDER(proxy), + new, sib); g_list_free(children); } g_list_free(list); } else { - kz_bookmark_prepend(KZ_BOOKMARK(proxy), new); + kz_bookmark_folder_prepend(KZ_BOOKMARK_FOLDER(proxy), new); } g_object_unref(new); } static void -cb_folder_remove_child (KzBookmark *folder, +cb_folder_remove_child (KzBookmarkFolder *folder, KzBookmark *child, KzProxyFolder *proxy) { @@ -284,19 +281,20 @@ gint index; KzProxyFolderPriv *priv = KZ_PROXY_FOLDER_GET_PRIVATE(proxy); - list = kz_bookmark_get_children(priv->bookmark); + list = kz_bookmark_folder_get_children(priv->folder); index = g_list_index(list, child); + g_list_free(list); + if (index >= 0) { GList *children; KzBookmark *remove; - children = kz_bookmark_get_children(KZ_BOOKMARK(proxy)); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(proxy)); remove = KZ_BOOKMARK(g_list_nth_data(children, index)); - kz_bookmark_remove(KZ_BOOKMARK(proxy), remove); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(proxy), remove); g_list_free(children); } - g_list_free(list); } @@ -309,17 +307,17 @@ KzBookmark *orig = NULL; KzProxyFolderPriv *priv = KZ_PROXY_FOLDER_GET_PRIVATE(proxy); - list = kz_bookmark_get_children(KZ_BOOKMARK(proxy)); + list = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(proxy)); index = g_list_index(list, bookmark); + g_list_free(list); if (index >= 0) { GList *children; - children = kz_bookmark_get_children(priv->bookmark); + children = kz_bookmark_folder_get_children(priv->folder); orig = KZ_BOOKMARK(g_list_nth_data(children, index)); g_list_free(children); } - g_list_free(list); return orig; } @@ -332,7 +330,7 @@ KzBookmark *orig = NULL; KzProxyFolderPriv *priv = KZ_PROXY_FOLDER_GET_PRIVATE(proxy); - list = kz_bookmark_get_children(priv->bookmark); + list = kz_bookmark_folder_get_children(priv->folder); orig = KZ_BOOKMARK(g_list_nth_data(list, index)); g_list_free(list); Modified: kazehakase/trunk/src/bookmarks/kz-proxy-folder.h =================================================================== --- kazehakase/trunk/src/bookmarks/kz-proxy-folder.h 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-proxy-folder.h 2009-02-12 03:06:11 UTC (rev 3627) @@ -18,13 +18,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Id$ */ #ifndef __KZ_PROXY_FOLDER_H__ #define __KZ_PROXY_FOLDER_H__ -#include "kz-bookmark.h" +#include "kz-bookmark-folder.h" G_BEGIN_DECLS @@ -42,16 +41,16 @@ struct _KzProxyFolder { - KzBookmark parent; + KzBookmarkFolder parent; }; struct _KzProxyFolderClass { - KzBookmarkClass parent_class; + KzBookmarkFolderClass parent_class; }; GType kz_proxy_folder_get_type (void) G_GNUC_CONST; -KzBookmark *kz_proxy_folder_new (KzBookmark *folder); +KzBookmark *kz_proxy_folder_new (KzBookmarkFolder *folder); KzBookmark *kz_proxy_folder_get_original_bookmark (KzProxyFolder *proxy, KzBookmark *bookmark); Modified: kazehakase/trunk/src/bookmarks/kz-root-bookmark.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-root-bookmark.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-root-bookmark.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Id$ */ #include "kz-root-bookmark.h" @@ -28,7 +27,7 @@ static void dispose (GObject *object); -G_DEFINE_TYPE(KzRootBookmark, kz_root_bookmark, KZ_TYPE_BOOKMARK) +G_DEFINE_TYPE(KzRootBookmark, kz_root_bookmark, KZ_TYPE_BOOKMARK_FOLDER) static void kz_root_bookmark_class_init (KzRootBookmarkClass *klass) @@ -46,9 +45,9 @@ { root->menu = KZ_BOOKMARK(kz_bookmark_file_new(NULL, NULL, NULL)); root->clip = KZ_BOOKMARK(kz_bookmark_file_new(NULL, NULL, NULL)); - root->bookmark_bars = kz_bookmark_pure_folder_new(); + root->bookmark_bars = kz_bookmark_folder_new(); root->history = kz_history_new(NULL); - root->tab_groups = kz_bookmark_pure_folder_new(); + root->tab_groups = kz_bookmark_folder_new(); root->smarts = NULL; root->current_session = NULL; @@ -114,16 +113,15 @@ KzRootBookmark *root; root = g_object_new(KZ_TYPE_ROOT_BOOKMARK, - "type", KZ_BOOKMARK_PURE_FOLDER, "title", _("Root"), NULL); if (root->menu) - kz_bookmark_append(KZ_BOOKMARK(root), root->menu); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(root), root->menu); if (root->clip) - kz_bookmark_append(KZ_BOOKMARK(root), root->clip); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(root), root->clip); if (root->bookmark_bars) - kz_bookmark_append(KZ_BOOKMARK(root), root->bookmark_bars); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(root), root->bookmark_bars); /* kz_bookmark_append(KZ_BOOKMARK(root), KZ_BOOKMARK(root->history)); kz_bookmark_append(KZ_BOOKMARK(root), root->windows); @@ -183,7 +181,7 @@ if (root->menu) { - kz_bookmark_remove(KZ_BOOKMARK(root), root->menu); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(root), root->menu); g_object_unref(root->menu); root->menu = NULL; } @@ -191,7 +189,7 @@ if (menu) { root->menu = menu; - kz_bookmark_insert_before(KZ_BOOKMARK(root), + kz_bookmark_folder_insert_before(KZ_BOOKMARK_FOLDER(root), menu, root->clip); } } @@ -211,7 +209,7 @@ if (root->clip) { - kz_bookmark_remove(KZ_BOOKMARK(root), root->clip); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(root), root->clip); g_object_unref(root->clip); root->clip = NULL; } @@ -219,8 +217,8 @@ if (clip) { root->clip = clip; - kz_bookmark_insert_before(KZ_BOOKMARK(root), - clip, root->smarts); + kz_bookmark_folder_insert_before(KZ_BOOKMARK_FOLDER(root), + clip, root->smarts); } } @@ -241,7 +239,7 @@ if (root->smarts) { - kz_bookmark_remove(KZ_BOOKMARK(root), root->smarts); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(root), root->smarts); g_object_unref(root->smarts); root->smarts = NULL; } @@ -249,8 +247,8 @@ if (smart) { root->smarts = smart; - kz_bookmark_insert_before(KZ_BOOKMARK(root), - smart, root->bookmark_bars); + kz_bookmark_folder_insert_before(KZ_BOOKMARK_FOLDER(root), + smart, root->bookmark_bars); } } @@ -290,7 +288,7 @@ kz_bookmark_file_load_start(bar); kz_bookmark_file_set_location(bar, file); - kz_bookmark_append(root->bookmark_bars, KZ_BOOKMARK(bar)); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(root->bookmark_bars), KZ_BOOKMARK(bar)); g_object_unref(bar); } @@ -328,7 +326,7 @@ { GList *children; - children = kz_bookmark_get_children(root->bookmark_bars); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(root->bookmark_bars)); for (node = children; node; node = g_list_next(node)) { KzBookmark *bar = node->data; Modified: kazehakase/trunk/src/bookmarks/kz-root-bookmark.h =================================================================== --- kazehakase/trunk/src/bookmarks/kz-root-bookmark.h 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-root-bookmark.h 2009-02-12 03:06:11 UTC (rev 3627) @@ -23,7 +23,7 @@ #ifndef __KZ_ROOT_BOOKMARK_H__ #define __KZ_ROOT_BOOKMARK_H__ -#include "kz-bookmark.h" +#include "kz-bookmark-folder.h" #include "kz-history.h" G_BEGIN_DECLS @@ -40,7 +40,7 @@ struct _KzRootBookmark { - KzBookmark parent; + KzBookmarkFolder parent; KzBookmark *menu; KzBookmark *bookmark_bars; @@ -57,9 +57,7 @@ struct _KzRootBookmarkClass { - KzBookmarkClass parent_class; - - /* -- signals -- */ + KzBookmarkFolderClass parent_class; }; GType kz_root_bookmark_get_type (void) G_GNUC_CONST; Modified: kazehakase/trunk/src/bookmarks/kz-rss.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-rss.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-rss.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -178,7 +178,7 @@ } } - kz_bookmark_append(bookmark, child); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(bookmark), child); g_object_unref(child); } Modified: kazehakase/trunk/src/bookmarks/kz-smart-bookmark.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-smart-bookmark.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-smart-bookmark.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -54,7 +54,7 @@ GValue *value, GParamSpec *pspec); -G_DEFINE_TYPE(KzSmartBookmark, kz_smart_bookmark, KZ_TYPE_BOOKMARK) +G_DEFINE_TYPE(KzSmartBookmark, kz_smart_bookmark, KZ_TYPE_BOOKMARK_FOLDER) static GQuark smart_list_quark = 0; Modified: kazehakase/trunk/src/bookmarks/kz-smart-bookmark.h =================================================================== --- kazehakase/trunk/src/bookmarks/kz-smart-bookmark.h 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-smart-bookmark.h 2009-02-12 03:06:11 UTC (rev 3627) @@ -23,7 +23,7 @@ #ifndef __KZ_SMART_BOOKMARK_H__ #define __KZ_SMART_BOOKMARK_H__ -#include "kz-bookmark.h" +#include "kz-bookmark-folder.h" G_BEGIN_DECLS @@ -47,12 +47,12 @@ struct _KzSmartBookmark { - KzBookmark parent; + KzBookmarkFolder parent; }; struct _KzSmartBookmarkClass { - KzBookmarkClass parent_class; + KzBookmarkFolderClass parent_class; }; GType kz_smart_bookmark_get_type (void) G_GNUC_CONST; Modified: kazehakase/trunk/src/bookmarks/kz-w3mbookmark.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-w3mbookmark.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-w3mbookmark.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -128,7 +128,7 @@ if (!strncasecmp(pos, "<h2", 3)) { gchar *folder_title; - KzBookmark *folder = kz_bookmark_pure_folder_new(); + KzBookmark *folder = kz_bookmark_folder_new(); /* folder title */ folder_title = xml_get_content(pos); @@ -140,7 +140,7 @@ pos += 3; pos = kz_w3mbookmark_parse_bookmark(folder, pos); - kz_bookmark_append(bookmark, folder); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(bookmark), folder); g_object_unref(folder); } else if (!strncasecmp(pos, "<a href=", 8)) @@ -160,7 +160,7 @@ g_free(title); } - kz_bookmark_append(bookmark, child); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(bookmark), child); g_object_unref(child); } else if (!strncasecmp(pos, "<ul>", 4)) Modified: kazehakase/trunk/src/bookmarks/kz-xbel.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-xbel.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/bookmarks/kz-xbel.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -26,6 +26,7 @@ #include "utils.h" #include "kz-smart-bookmark.h" #include "kz-bookmark-separator.h" +#include "kz-bookmark-folder.h" #include <string.h> #include <stdlib.h> @@ -143,10 +144,6 @@ g_object_set_qdata_full(G_OBJECT(bookmark), xml_quark, xml, (GDestroyNotify) g_object_unref); - g_object_set(bookmark, - "type", KZ_BOOKMARK_PURE_FOLDER, - NULL); - g_signal_connect(bookmark, "notify", G_CALLBACK(kz_xbel_notify), xml); g_signal_connect_after(bookmark, "insert-child", @@ -388,24 +385,24 @@ else if (!strcmp(attr->name, "kz:current_position")) { guint pos = (guint)atoi(attr->value); - kz_bookmark_set_current(bookmark, pos); + kz_bookmark_folder_set_current_position(KZ_BOOKMARK_FOLDER(bookmark), pos); } else if (!strcmp(attr->name, "kz:lock")) { if (!strcmp(attr->value, "yes")) - kz_bookmark_set_lock(bookmark, TRUE); + kz_bookmark_folder_set_lock(KZ_BOOKMARK_FOLDER(bookmark), TRUE); } else if (!strcmp(attr->name, "kz:auto_refresh")) { if (!strcmp(attr->value, "yes")) - kz_bookmark_set_auto_refresh(bookmark, TRUE); + kz_bookmark_folder_set_auto_refresh(KZ_BOOKMARK_FOLDER(bookmark), TRUE); } else if (!strcmp(attr->name, "kz:javascript")) { if (!strcmp(attr->value, "yes")) - kz_bookmark_set_javascript(bookmark, TRUE); + kz_bookmark_folder_set_javascript(KZ_BOOKMARK_FOLDER(bookmark), TRUE); if (!strcmp(attr->value, "no")) - kz_bookmark_set_javascript(bookmark, FALSE); + kz_bookmark_folder_set_javascript(KZ_BOOKMARK_FOLDER(bookmark), FALSE); } } @@ -594,12 +591,12 @@ } else { - folder = kz_bookmark_pure_folder_new(); + folder = kz_bookmark_folder_new(); } folded_str = kz_xml_node_get_attr(node, "folded"); folded = folded_str && !strcmp(folded_str, "yes"); - kz_bookmark_set_folded(folder, folded); + kz_bookmark_folder_set_folded(KZ_BOOKMARK_FOLDER(folder), folded); id = kz_xml_node_get_attr(node, "id"); if (id) @@ -608,7 +605,7 @@ BOOKMARK_SET_BUILDING(folder); g_object_set_qdata(G_OBJECT(folder), node_quark, node); - kz_bookmark_append(bookmark, folder); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(bookmark), folder); parse_child_node(folder, node); BOOKMARK_UNSET_BUILDING(folder); @@ -663,7 +660,7 @@ * because smart bookmark action needs bookmark title * in child's nodes. */ - kz_bookmark_append(bookmark, child_bookmark); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(bookmark), child_bookmark); BOOKMARK_UNSET_BUILDING(bookmark); g_object_unref(child_bookmark); } @@ -674,7 +671,7 @@ BOOKMARK_SET_BUILDING(separator); g_object_set_qdata(G_OBJECT(separator), node_quark, node); - kz_bookmark_append(bookmark, separator); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(bookmark), separator); BOOKMARK_UNSET_BUILDING(separator); g_object_unref(separator); } @@ -1038,10 +1035,11 @@ else if (kz_bookmark_is_folder(bookmark)) { KzXMLNode *metanode; - gint pos = kz_bookmark_get_current(bookmark); - gboolean lock = kz_bookmark_get_lock(bookmark); - gboolean auto_refresh = kz_bookmark_get_auto_refresh(bookmark); - gboolean javascript = kz_bookmark_get_javascript(bookmark); + KzBookmarkFolder *folder = KZ_BOOKMARK_FOLDER(bookmark); + gint pos = kz_bookmark_folder_get_current_position(folder); + gboolean lock = kz_bookmark_folder_get_lock(folder); + gboolean auto_refresh = kz_bookmark_folder_get_auto_refresh(folder); + gboolean javascript = kz_bookmark_folder_get_javascript(folder); /* * <folder>\n * <title/> @@ -1188,7 +1186,7 @@ { GList *node, *children; - children = kz_bookmark_get_children(bookmark); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(bookmark)); for (node = children; node; node = g_list_next(node)) { KzBookmark *child = node->data; @@ -1220,7 +1218,7 @@ { GList *node, *children; - children = kz_bookmark_get_children(bookmark); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(bookmark)); for (node = children; node; node = g_list_next(node)) { KzBookmark *child = node->data; @@ -1604,7 +1602,7 @@ { GList *node, *children; - children = kz_bookmark_get_children(bookmark); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(bookmark)); for (node = children; node; node = g_list_next(node)) { KzBookmark *child = node->data; @@ -1626,7 +1624,7 @@ { GList *node, *children; - children = kz_bookmark_get_children(bookmark); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(bookmark)); for (node = children; node; node = g_list_next(node)) { KzBookmark *child = node->data; Modified: kazehakase/trunk/src/kz-app.c =================================================================== --- kazehakase/trunk/src/kz-app.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/kz-app.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -703,8 +703,8 @@ for (node = priv->window_list; node; node = g_list_next(node)) { KzWindow *kz = KZ_WINDOW(node->data); - kz_bookmark_remove(priv->bookmarks->current_session, - kz->tabs); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(priv->bookmarks->current_session), + kz->tabs); kz_window_close_all_tab(kz); } @@ -713,7 +713,7 @@ if (g_file_test(location, G_FILE_TEST_EXISTS)) kz_bookmark_file_load(KZ_BOOKMARK_FILE(session)); - list = kz_bookmark_get_children(session); + list = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(session)); window_node = priv->window_list; /* windows */ @@ -762,8 +762,8 @@ if (!kz_session_is_frozen(KZ_SESSION(priv->bookmarks->current_session))) { - kz_bookmark_append(priv->bookmarks->current_session, - KZ_WINDOW(window)->tabs); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(priv->bookmarks->current_session), + KZ_WINDOW(window)->tabs); } g_signal_connect(window, "destroy", @@ -962,8 +962,8 @@ else { if (kz->tabs) - kz_bookmark_remove(priv->bookmarks->current_session, - kz->tabs); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(priv->bookmarks->current_session), + kz->tabs); } } Modified: kazehakase/trunk/src/kz-embed.c =================================================================== --- kazehakase/trunk/src/kz-embed.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/kz-embed.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -652,7 +652,7 @@ if (!KZ_EMBED_GET_IFACE(dest_embed)->set_history) return; - history = kz_bookmark_pure_folder_new(); + history = kz_bookmark_folder_new(); kz_embed_get_history(src_embed, history); kz_embed_set_history(dest_embed, history); g_object_unref(history); Modified: kazehakase/trunk/src/kz-navi.c =================================================================== --- kazehakase/trunk/src/kz-navi.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/kz-navi.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -119,7 +119,7 @@ g_return_if_fail(navi); g_return_if_fail(navi->uri); - bars = kz_bookmark_get_children(KZ_GET_BAR_BOOKMARK); + bars = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(KZ_GET_BAR_BOOKMARK)); g_return_if_fail(bars); folder = bars->data; @@ -138,9 +138,9 @@ bookmark = KZ_BOOKMARK(kz_bookmark_file_new(uri, title, NULL)); /* FIXME! show dialog */ if (sibling) - kz_bookmark_insert_before(folder, bookmark, sibling); + kz_bookmark_folder_insert_before(KZ_BOOKMARK_FOLDER(folder), bookmark, sibling); else - kz_bookmark_append(folder, bookmark); + kz_bookmark_folder_append(KZ_BOOKMARK_FOLDER(folder), bookmark); if (KZ_IS_BOOKMARK_FILE(folder)) file = folder; Modified: kazehakase/trunk/src/kz-notebook.c =================================================================== --- kazehakase/trunk/src/kz-notebook.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/kz-notebook.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -387,10 +387,10 @@ kztab = KZ_TAB_LABEL(gtk_notebook_get_tab_label(notebook, child)); g_object_ref(kztab->history); - kz_bookmark_remove(kz->tabs, kztab->history); - kz_bookmark_insert_before(kz->tabs, - kztab->history, - sib_bookmark); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(kz->tabs), kztab->history); + kz_bookmark_folder_insert_before(KZ_BOOKMARK_FOLDER(kz->tabs), + kztab->history, + sib_bookmark); g_object_unref(kztab->history); } @@ -402,7 +402,7 @@ KZ_CONF_GET("Tab", "new_tab_position", pos_str, STRING); - if (!pos_str || !strcasecmp(pos_str, "last")) + if (pos_str[0] == '\0' || !strcasecmp(pos_str, "last")) { pos = -1; } Modified: kazehakase/trunk/src/kz-popup-tablist.c =================================================================== --- kazehakase/trunk/src/kz-popup-tablist.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/kz-popup-tablist.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -235,7 +235,7 @@ priv->now_shown = TRUE; gtk_window_set_position (GTK_WINDOW (popup), GTK_WIN_POS_CENTER); - list = kz_bookmark_get_children(tabs); + list = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(tabs)); length = g_list_length(list); g_list_free(list); Modified: kazehakase/trunk/src/kz-tab-label.c =================================================================== --- kazehakase/trunk/src/kz-tab-label.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/kz-tab-label.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -223,7 +223,7 @@ kztab->circle = NULL; kztab->mask = NULL; - kztab->history = kz_bookmark_pure_folder_new(); + kztab->history = kz_bookmark_folder_new(); kz_bookmark_set_title(kztab->history, _("Tab")); hbox = gtk_hbox_new(FALSE, 0); @@ -366,8 +366,8 @@ if (kztab->history) { - kz_bookmark_set_javascript(kztab->history, priv->javascript); - kz_bookmark_remove(kztab->kz->tabs, kztab->history); + kz_bookmark_folder_set_javascript(KZ_BOOKMARK_FOLDER(kztab->history), priv->javascript); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(kztab->kz->tabs), kztab->history); kz_window_append_closed_tab(kztab->kz, kztab->history); g_object_unref(kztab->history); kztab->history = NULL; @@ -884,7 +884,7 @@ g_return_if_fail(KZ_IS_TAB_LABEL(kztab)); - bookmark = kz_bookmark_get_current_bookmark(kztab->history); + bookmark = kz_bookmark_folder_get_current_bookmark(KZ_BOOKMARK_FOLDER(kztab->history)); if (bookmark) kz_bookmark_set_link(bookmark, kz_embed_get_location(embed)); } @@ -924,7 +924,7 @@ KzBookmark *bookmark; guint last_modified, last_visited = 0; - bookmark = kz_bookmark_get_current_bookmark(kztab->history); + bookmark = kz_bookmark_folder_get_current_bookmark(KZ_BOOKMARK_FOLDER(kztab->history)); if (bookmark) last_visited = kz_bookmark_get_last_visited(bookmark); last_modified = kz_embed_get_last_modified(embed); @@ -1037,7 +1037,7 @@ kz_embed_set_lock(kztab->kzembed, lock); kz_actions_set_sensitive(kztab->kz, kztab->kzembed); - kz_bookmark_set_lock(kztab->history, lock); + kz_bookmark_folder_set_lock(KZ_BOOKMARK_FOLDER(kztab->history), lock); kz_tab_label_sync_to_profile(kztab); } @@ -1063,7 +1063,7 @@ kz_embed_set_allow_javascript(kztab->kzembed, javascript); kz_actions_set_sensitive(kztab->kz, kztab->kzembed); - kz_bookmark_set_javascript(kztab->history, javascript); + kz_bookmark_folder_set_javascript(KZ_BOOKMARK_FOLDER(kztab->history), javascript); kz_tab_label_sync_to_profile(kztab); } @@ -1130,7 +1130,7 @@ priv->auto_refresh = auto_refresh; kz_actions_set_sensitive(kztab->kz, kztab->kzembed); - kz_bookmark_set_auto_refresh(kztab->history, auto_refresh); + kz_bookmark_folder_set_auto_refresh(KZ_BOOKMARK_FOLDER(kztab->history), auto_refresh); kz_tab_label_sync_to_profile(kztab); } @@ -1144,16 +1144,13 @@ g_object_unref(kztab->history); kztab->history = g_object_ref(history); - if (kz_bookmark_get_lock(history)) - { + if (kz_bookmark_folder_get_lock(KZ_BOOKMARK_FOLDER(history))) kz_tab_label_set_lock(kztab, TRUE); - } - if (kz_bookmark_get_auto_refresh(history)) - { + + if (kz_bookmark_folder_get_auto_refresh(KZ_BOOKMARK_FOLDER(history))) kz_tab_label_set_auto_refresh(kztab, TRUE); - } - allow_javacript = kz_bookmark_get_javascript(history); + allow_javacript = kz_bookmark_folder_get_javascript(KZ_BOOKMARK_FOLDER(history)); kz_embed_set_allow_javascript(KZ_EMBED(kztab->kzembed), allow_javacript); kz_tab_label_set_javascript(kztab, allow_javacript); @@ -1168,14 +1165,14 @@ g_get_current_time(&now); - bookmark = kz_bookmark_get_current_bookmark(kztab->history); + bookmark = kz_bookmark_folder_get_current_bookmark(KZ_BOOKMARK_FOLDER(kztab->history)); if (bookmark) kz_bookmark_set_last_visited(bookmark, now.tv_sec); /* find the bookmark which has the same uri from the system bookmark */ uri = kz_embed_get_location(kztab->kzembed); - bookmark = kz_bookmark_find_bookmark_from_uri(KZ_GET_MENU_BOOKMARK, - uri); + bookmark = kz_bookmark_folder_find_bookmark_from_uri(KZ_BOOKMARK_FOLDER(KZ_GET_MENU_BOOKMARK), + uri); if (bookmark) kz_bookmark_set_last_visited(bookmark, now.tv_sec); } Modified: kazehakase/trunk/src/kz-thumbnails-view.c =================================================================== --- kazehakase/trunk/src/kz-thumbnails-view.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/kz-thumbnails-view.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -273,7 +273,7 @@ priv->folder = g_object_ref(folder); connect_bookmark_signals(view, priv->folder); - children = kz_bookmark_get_children(folder); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(folder)); for (node = children; node; node = g_list_next(node)) { insert_bookmark(view, priv->folder, @@ -306,7 +306,7 @@ gint index; KzThumbnailsViewPrivate *priv = KZ_THUMBNAILS_VIEW_GET_PRIVATE (view); - children = kz_bookmark_get_children(priv->folder); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(priv->folder)); index = g_list_index(children, bookmark); g_list_free(children); @@ -390,7 +390,7 @@ { GList *children; - children = kz_bookmark_get_children(bookmark); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(bookmark)); pos = g_list_index(children, sibling); g_list_free(children); } @@ -503,7 +503,7 @@ bookmark = g_object_get_data(G_OBJECT(thumbnail), KZ_THUMBNAIL_BOOKMARK_KEY); - children = kz_bookmark_get_children(priv->folder); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(priv->folder)); index = g_list_index(children, bookmark); g_list_free(children); Modified: kazehakase/trunk/src/kz-window.c =================================================================== --- kazehakase/trunk/src/kz-window.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/kz-window.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -398,7 +398,7 @@ kz->top_vbox = gtk_vbox_new(FALSE, 0); kz->bookmark_bars_area = gtk_vbox_new(FALSE, 0); - children = kz_bookmark_get_children(KZ_GET_BAR_BOOKMARK); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(KZ_GET_BAR_BOOKMARK)); for (node = children; node; node = g_list_next(node)) { GtkWidget *bar = GTK_WIDGET(kz_bookmark_bar_new(kz, node->data)); @@ -434,9 +434,9 @@ priv->sidebar_was_shown = FALSE; - kz->tabs = kz_bookmark_pure_folder_new(); - kz->closed_tabs = kz_bookmark_pure_folder_new(); - kz->history_search = kz_bookmark_pure_folder_new(); + kz->tabs = kz_bookmark_folder_new(); + kz->closed_tabs = kz_bookmark_folder_new(); + kz->history_search = kz_bookmark_folder_new(); kz_ext_setup(kz); @@ -862,9 +862,9 @@ kz_notebook_open_new_tab(KZ_NOTEBOOK(kz->notebook), kzembed, kztab); sibtab = kz_notebook_get_sibling_tab_label(KZ_NOTEBOOK(kz->notebook), kztab); /* insert tab bookmark */ - kz_bookmark_insert_before(kz->tabs, - kztab->history, - sibtab ? sibtab->history : NULL); + kz_bookmark_folder_insert_before(KZ_BOOKMARK_FOLDER(kz->tabs), + kztab->history, + sibtab ? sibtab->history : NULL); kz_window_set_embed_callbacks(kz, kzembed); @@ -892,7 +892,7 @@ g_object_unref(kz->tabs); kz->tabs = g_object_ref(tabs); - childtabs = kz_bookmark_get_children(tabs); + childtabs = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(tabs)); /* tabs */ for (tabnode = childtabs; tabnode; tabnode = g_list_next(tabnode)) { @@ -911,7 +911,7 @@ } g_list_free(childtabs); - pos = kz_bookmark_get_current(tabs); + pos = kz_bookmark_folder_get_current_position(KZ_BOOKMARK_FOLDER(tabs)); kz_notebook_set_current_page(KZ_NOTEBOOK(kz->notebook), pos); curembed = KZ_EMBED(KZ_WINDOW_NTH_PAGE(kz, pos)); if (curembed) @@ -977,7 +977,7 @@ kz_notebook_move_tab(KZ_NOTEBOOK(src_notebook), KZ_NOTEBOOK(dest_notebook), widget); - kz_bookmark_prepend(dest_kz->tabs, new_kztab->history); + kz_bookmark_folder_prepend(KZ_BOOKMARK_FOLDER(dest_kz->tabs), new_kztab->history); kz_window_set_embed_callbacks(dest_kz, kzembed); g_signal_emit(src_kz, @@ -1781,7 +1781,7 @@ gtk_widget_show(bar); /* reorder */ - children = kz_bookmark_get_children(bookmark); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(bookmark)); pos = g_list_index(children, child); gtk_box_reorder_child(GTK_BOX(kz->bookmark_bars_area), bar, pos); @@ -1849,7 +1849,7 @@ g_return_if_fail(KZ_IS_WINDOW(kz)); - children = kz_bookmark_get_children(bookmark); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(bookmark)); for (node = children; node; node = g_list_next(node)) { GtkWidget *bar; @@ -1984,7 +1984,7 @@ /* set current_position in history */ /* FIXME: KzSession should block automatically */ if (!kz_session_is_frozen(KZ_SESSION(KZ_GET_CURRENT_SESSION))) - kz_bookmark_set_current(kz->tabs, page_num); + kz_bookmark_folder_set_current_position(KZ_BOOKMARK_FOLDER(kz->tabs), page_num); } static void @@ -2540,16 +2540,16 @@ { GList *children; - kz_bookmark_prepend(kz->closed_tabs, bookmark); + kz_bookmark_folder_prepend(KZ_BOOKMARK_FOLDER(kz->closed_tabs), bookmark); /* removed the oldest one */ - children = kz_bookmark_get_children(kz->closed_tabs); + children = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(kz->closed_tabs)); if (children) { KzBookmark *last; last = g_list_nth_data(children, MAX_CLOSED_TABS); if (last) - kz_bookmark_remove(kz->closed_tabs, last); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(kz->closed_tabs), last); g_list_free(children); } } Modified: kazehakase/trunk/src/sidebar/kz-thumbnails-sidebar.c =================================================================== --- kazehakase/trunk/src/sidebar/kz-thumbnails-sidebar.c 2009-02-12 02:32:04 UTC (rev 3626) +++ kazehakase/trunk/src/sidebar/kz-thumbnails-sidebar.c 2009-02-12 03:06:11 UTC (rev 3627) @@ -235,7 +235,7 @@ * create a new bookmark folder which included each current page of * closed tab. */ - proxy = kz_proxy_folder_new(sidebar->kz->closed_tabs); + proxy = kz_proxy_folder_new(KZ_BOOKMARK_FOLDER(sidebar->kz->closed_tabs)); kz_thumbnails_view_set_folder(KZ_THUMBNAILS_VIEW(tsidebar->view), proxy); @@ -297,7 +297,7 @@ g_return_if_fail(KZ_IS_BOOKMARK(bookmark)); g_return_if_fail(KZ_IS_WINDOW(kz)); - list = kz_bookmark_get_children(kz->closed_tabs); + list = kz_bookmark_folder_get_children(KZ_BOOKMARK_FOLDER(kz->closed_tabs)); tab = KZ_BOOKMARK(g_list_nth_data(list, index)); g_list_free(list); g_return_if_fail(tab); @@ -308,5 +308,5 @@ kzembed)); kz_tab_label_set_history(KZ_TAB_LABEL(kztab), tab); - kz_bookmark_remove(kz->closed_tabs, tab); + kz_bookmark_folder_remove(KZ_BOOKMARK_FOLDER(kz->closed_tabs), tab); }