[Kazehakase-cvs] CVS update: kazehakase/src/bookmarks

Back to archive index

Kouhei Sutou kous****@users*****
Sat Jan 20 14:09:01 JST 2007


Index: kazehakase/src/bookmarks/kz-bookmark-tab-menu.c
diff -u kazehakase/src/bookmarks/kz-bookmark-tab-menu.c:1.10 kazehakase/src/bookmarks/kz-bookmark-tab-menu.c:1.11
--- kazehakase/src/bookmarks/kz-bookmark-tab-menu.c:1.10	Sun Dec 31 10:59:41 2006
+++ kazehakase/src/bookmarks/kz-bookmark-tab-menu.c	Sat Jan 20 14:09:01 2007
@@ -18,7 +18,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
- *  $Id: kz-bookmark-tab-menu.c,v 1.10 2006/12/31 01:59:41 ikezoe Exp $
+ *  $Id: kz-bookmark-tab-menu.c,v 1.11 2007/01/20 05:09:01 kous Exp $
  */
 
 #include "kz-bookmark-tab-menu.h"
@@ -405,6 +405,38 @@
 	kz_bookmark_menu_append_tab_menuitems(shell, kz, item);
 }
 
+static GList *
+cb_folder_get_children (KzBookmark *item, GtkMenuShell *shell)
+{
+	GList *child, *children = NULL, *last_children = NULL;
+
+	for (child = shell->children; child; child = g_list_next(child))
+	{
+		KzBookmark *bookmark;
+		bookmark = g_object_get_data(G_OBJECT(child->data),
+					     KZ_BOOKMARK_TAB_MENU_BOOKMARK_KEY);
+		if (!children)
+		{
+			children = g_list_append(children, bookmark);
+			last_children = children;
+		}
+		else
+		{
+			GList *result;
+			result = g_list_append(last_children, bookmark);
+			last_children = g_list_next(result);
+		}
+	}
+
+	return children;
+}
+
+static gboolean
+cb_folder_has_children (KzBookmark *item, GtkMenuShell *shell)
+{
+	return shell->children != NULL;
+}
+
 
 static void
 folder_weak_ref (gpointer data, GObject *obj)
@@ -435,6 +467,12 @@
 	g_signal_connect_after(folder, "children-reordered",
 			       G_CALLBACK(cb_folder_reordered),
 			       shell);
+	g_signal_connect_after(folder, "get-children",
+			       G_CALLBACK(cb_folder_get_children),
+			       shell);
+	g_signal_connect_after(folder, "has-children",
+			       G_CALLBACK(cb_folder_has_children),
+			       shell);
 
 	g_signal_connect(shell, "destroy",
 			 G_CALLBACK(cb_root_menu_destroy), folder);
@@ -457,6 +495,14 @@
 		(folder,
 		 G_CALLBACK(cb_folder_reordered),
 		 shell);
+	g_signal_handlers_disconnect_by_func
+		(folder,
+		 G_CALLBACK(cb_folder_get_children),
+		 shell);
+	g_signal_handlers_disconnect_by_func
+		(folder,
+		 G_CALLBACK(cb_folder_has_children),
+		 shell);
 
 	g_object_weak_unref(G_OBJECT(folder), folder_weak_ref, shell);
 }
Index: kazehakase/src/bookmarks/kz-bookmark.c
diff -u kazehakase/src/bookmarks/kz-bookmark.c:1.82 kazehakase/src/bookmarks/kz-bookmark.c:1.83
--- kazehakase/src/bookmarks/kz-bookmark.c:1.82	Sat Dec  2 18:57:25 2006
+++ kazehakase/src/bookmarks/kz-bookmark.c	Sat Jan 20 14:09:01 2007
@@ -18,7 +18,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
- *  $Id: kz-bookmark.c,v 1.82 2006/12/02 09:57:25 ikezoe Exp $
+ *  $Id: kz-bookmark.c,v 1.83 2007/01/20 05:09:01 kous Exp $
  */
 
 #include "kz-bookmark.h"
@@ -37,6 +37,8 @@
 	REMOVE_CHILD_SIGNAL,
 	MOVE_CHILD_SIGNAL,
 	CHILDREN_REORDERED_SIGNAL,
+	GET_CHILDREN_SIGNAL,
+	HAS_CHILDREN_SIGNAL,
 	LAST_SIGNAL
 };
 
@@ -74,6 +76,8 @@
 					   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};
 
@@ -110,6 +114,8 @@
 	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,
@@ -290,6 +296,24 @@
 				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:
@@ -898,13 +922,11 @@
 }
 
 
-GList *
-kz_bookmark_get_children (KzBookmark *bookmark)
+static GList *
+kz_bookmark_real_get_children (KzBookmark *bookmark)
 {
 	GList *list;
 
-	g_return_val_if_fail(KZ_IS_BOOKMARK(bookmark), NULL);
-
 	list =  g_object_get_qdata(G_OBJECT(bookmark), children_quark);
 
 	if (list)
@@ -913,14 +935,25 @@
 	return NULL;
 }
 
+GList *
+kz_bookmark_get_children (KzBookmark *bookmark)
+{
+	GList *result;
 
-gboolean
-kz_bookmark_has_children (KzBookmark  *bookmark)
+	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;
 
-	g_return_val_if_fail(KZ_IS_BOOKMARK(bookmark), FALSE);
-
 	list =  g_object_get_qdata(G_OBJECT(bookmark), children_quark);
 
 	if (list)
@@ -929,6 +962,18 @@
 		return FALSE;
 }
 
+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)
Index: kazehakase/src/bookmarks/kz-bookmark.h
diff -u kazehakase/src/bookmarks/kz-bookmark.h:1.36 kazehakase/src/bookmarks/kz-bookmark.h:1.37
--- kazehakase/src/bookmarks/kz-bookmark.h:1.36	Sun Apr 23 23:42:25 2006
+++ kazehakase/src/bookmarks/kz-bookmark.h	Sat Jan 20 14:09:01 2007
@@ -18,7 +18,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
- *  $Id: kz-bookmark.h,v 1.36 2006/04/23 14:42:25 kous Exp $
+ *  $Id: kz-bookmark.h,v 1.37 2007/01/20 05:09:01 kous Exp $
  */
 
 #ifndef __KZ_BOOKMARK_H__
@@ -73,6 +73,9 @@
 				    KzBookmark  *parent,
 				    KzBookmark  *sibling);
 	void (*children_reordered) (KzBookmark  *boomark);
+
+	GList    *(*get_children)  (KzBookmark  *boomark);
+	gboolean  (*has_children)  (KzBookmark  *boomark);
 };
 
 


More information about the Kazehakase-cvs mailing list
Back to archive index