svnno****@sourc*****
svnno****@sourc*****
Thu Oct 4 11:58:49 JST 2007
Revision: 3259 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3259 Author: ikezoe Date: 2007-10-04 11:58:48 +0900 (Thu, 04 Oct 2007) Log Message: ----------- 2007-10-04 Hiroyuki Ikezoe <poinc****@ikezo*****> * src/bookmarks/kz-bookmark-utils.[ch]: Added. * src/bookmarks/kz-bookmark-bar.c, src/bookmarks/kz-bookmarks-item.c: Use kz_bookmark_create_from_selection_data(). Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/src/bookmarks/Makefile.am kazehakase/trunk/src/bookmarks/kz-bookmark-bar.c kazehakase/trunk/src/bookmarks/kz-bookmark-item.c Added Paths: ----------- kazehakase/trunk/src/bookmarks/kz-bookmark-utils.c kazehakase/trunk/src/bookmarks/kz-bookmark-utils.h Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2007-10-04 00:47:49 UTC (rev 3258) +++ kazehakase/trunk/ChangeLog 2007-10-04 02:58:48 UTC (rev 3259) @@ -1,3 +1,9 @@ +2007-10-04 Hiroyuki Ikezoe <poinc****@ikezo*****> + + * src/bookmarks/kz-bookmark-utils.[ch]: Added. + * src/bookmarks/kz-bookmark-bar.c, src/bookmarks/kz-bookmarks-item.c: + Use kz_bookmark_create_from_selection_data(). + 2007-10-04 Kouhei Sutou <kou****@cozmi*****> * src/Makefile.am: fixed wrong dependencies. Modified: kazehakase/trunk/src/bookmarks/Makefile.am =================================================================== --- kazehakase/trunk/src/bookmarks/Makefile.am 2007-10-04 00:47:49 UTC (rev 3258) +++ kazehakase/trunk/src/bookmarks/Makefile.am 2007-10-04 02:58:48 UTC (rev 3259) @@ -50,6 +50,7 @@ kz-bookmark-edit.h \ kz-bookmark-editor.h \ kz-bookmark-edit-win.h \ + kz-bookmark-utils.h \ kz-actions-bookmark.h \ kz-session.h \ kz-w3mbookmark.h @@ -88,6 +89,7 @@ kz-bookmark-edit.c \ kz-bookmark-editor.c \ kz-bookmark-edit-win.c \ + kz-bookmark-utils.c \ kz-actions-bookmark.c \ kz-session.c \ kz-w3mbookmark.c \ Modified: kazehakase/trunk/src/bookmarks/kz-bookmark-bar.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark-bar.c 2007-10-04 00:47:49 UTC (rev 3258) +++ kazehakase/trunk/src/bookmarks/kz-bookmark-bar.c 2007-10-04 02:58:48 UTC (rev 3259) @@ -35,6 +35,7 @@ #include "kz-bookmark-item.h" #include "kz-bookmark.h" #include "kz-bookmark-file.h" +#include "kz-bookmark-utils.h" #include "kz-actions.h" #include "kz-notebook.h" #include "utils.h" @@ -391,54 +392,6 @@ } -static KzBookmark * -create_bookmark_from_selection_data (GtkSelectionData *seldata) -{ - KzBookmark *bookmark; - gchar **strings = NULL; - gchar *utf8_title = NULL; - const gchar *title; - - if (seldata->length < 0) - return NULL; - - strings = g_strsplit((const gchar*)seldata->data, "\n", 2); - if (!strings) - return NULL; - - if (strings[1] != NULL) - { - utf8_title = g_locale_to_utf8(strings[1], - strlen(strings[1]), - NULL, - NULL, - NULL); - } - if (utf8_title && g_utf8_validate(utf8_title, -1, NULL)) - title = utf8_title; - else - title = _("title"); - - /* FIXME! we should also add normal bookmark. */ - /* Create New KzBookmark */ - if (strstr(strings[0], "xml") || - strstr(strings[0], "rss") || - strstr(strings[0], "rdf")) - { - bookmark = KZ_BOOKMARK(kz_bookmark_file_new(strings[0], - title, - NULL)); - } - else - { - bookmark = kz_bookmark_new_with_attrs(title, strings[0], NULL); - } - g_strfreev(strings); - if (utf8_title) - g_free(utf8_title); - return bookmark; -} - static void drag_data_received (GtkWidget *widget, GdkDragContext *context, @@ -497,7 +450,7 @@ break; case TARGET_NETSCAPE_URL: case TARGET_TEXT_URI_LIST: - bookmark = create_bookmark_from_selection_data(data); + bookmark = kz_bookmark_create_from_selection_data(data); break; default: break; Modified: kazehakase/trunk/src/bookmarks/kz-bookmark-item.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark-item.c 2007-10-04 00:47:49 UTC (rev 3258) +++ kazehakase/trunk/src/bookmarks/kz-bookmark-item.c 2007-10-04 02:58:48 UTC (rev 3259) @@ -32,6 +32,7 @@ #include "kz-bookmark-menu-item.h" #include "kz-bookmark-folder-menu-item.h" #include "kz-bookmark-editor.h" +#include "kz-bookmark-utils.h" #include "kz-icons.h" #include "kz-actions.h" #include "gtk-utils.h" @@ -657,11 +658,9 @@ gpointer data) { KzBookmarkItem *item; - KzBookmark *bookmark, *parent, *file; - gchar **strings = NULL; + KzBookmark *bookmark = NULL, *parent, *file; GtkWidget *src_widget; - const gchar *title; - gchar *utf8_title = NULL; + gboolean success = FALSE, moved = FALSE; item = KZ_BOOKMARK_ITEM(widget); switch (info) @@ -674,93 +673,42 @@ bookmark = KZ_BOOKMARK_ITEM(src_widget)->bookmark; g_object_ref(bookmark); - parent = kz_bookmark_get_parent(bookmark); kz_bookmark_remove(parent, bookmark); - - kz_bookmark_append(item->bookmark, bookmark); - if (KZ_IS_BOOKMARK_FILE(item->bookmark)) - file = item->bookmark; - else - file = kz_bookmark_get_parent_file(item->bookmark); - - if (kz_bookmark_file_has_xmlrpc(KZ_BOOKMARK_FILE(file))) - { - kz_bookmark_file_xmlrpc_insert(KZ_BOOKMARK_FILE(file), - item->bookmark, - NULL, - bookmark); - } - else - { - kz_bookmark_file_save(KZ_BOOKMARK_FILE(file)); - } - - gtk_drag_finish(context, TRUE, TRUE, time); + moved = TRUE; break; case TARGET_NETSCAPE_URL: case TARGET_TEXT_URI_LIST: - if (selection_data->length < 0) return; - strings = g_strsplit((const gchar*)selection_data->data, "\n", 2); - if (!strings) return; - if (strings[1] != NULL) - { - utf8_title = g_locale_to_utf8(strings[1], - strlen(strings[1]), - NULL, - NULL, - NULL); - } - if (utf8_title && g_utf8_validate(utf8_title, -1, NULL)) - title = utf8_title; - else - title = _("Title"); - - /* FIXME! we should also add normal bookmark. */ - /* Create New KzBookmark */ - if (strstr(strings[0], "xml") || - strstr(strings[0], "rss") || - strstr(strings[0], "rdf")) - { - bookmark = KZ_BOOKMARK(kz_bookmark_file_new(strings[0], - title, - NULL)); - } - else - { - bookmark = kz_bookmark_new_with_attrs(title, - strings[0], - NULL); - } + bookmark = kz_bookmark_create_from_selection_data(selection_data); kz_bookmark_append(item->bookmark, bookmark); - g_strfreev(strings); - if (utf8_title) - g_free(utf8_title); - g_object_unref(bookmark); + break; + default: + break; + } + if (bookmark) + { + kz_bookmark_append(item->bookmark, bookmark); if (KZ_IS_BOOKMARK_FILE(item->bookmark)) file = item->bookmark; else file = kz_bookmark_get_parent_file(item->bookmark); - + if (kz_bookmark_file_has_xmlrpc(KZ_BOOKMARK_FILE(file))) { kz_bookmark_file_xmlrpc_insert(KZ_BOOKMARK_FILE(file), - item->bookmark, - NULL, - bookmark); + item->bookmark, + NULL, + bookmark); } else { kz_bookmark_file_save(KZ_BOOKMARK_FILE(file)); } - - gtk_drag_finish(context, TRUE, FALSE, time); - break; - default: - gtk_drag_finish(context, FALSE, FALSE, time); - break; + g_object_unref(bookmark); + success = TRUE; } + gtk_drag_finish(context, success, moved, time); } Added: kazehakase/trunk/src/bookmarks/kz-bookmark-utils.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark-utils.c 2007-10-04 00:47:49 UTC (rev 3258) +++ kazehakase/trunk/src/bookmarks/kz-bookmark-utils.c 2007-10-04 02:58:48 UTC (rev 3259) @@ -0,0 +1,77 @@ +/* -*- 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. + * + * $Id: kz-bookmark.h 2819 2007-01-20 05:09:01Z kous $ + */ + +#include "kz-bookmark-utils.h" + +#include <glib/gi18n.h> +#include <string.h> + +#include "kz-bookmark-file.h" + +KzBookmark * +kz_bookmark_create_from_selection_data (GtkSelectionData *seldata) +{ + KzBookmark *bookmark; + gchar **strings = NULL; + gchar *utf8_title = NULL; + const gchar *title; + + if (seldata->length < 0) + return NULL; + + strings = g_strsplit((const gchar*)seldata->data, "\n", 2); + if (!strings) + return NULL; + + if (strings[1] != NULL) + { + utf8_title = g_locale_to_utf8(strings[1], + strlen(strings[1]), + NULL, + NULL, + NULL); + } + if (utf8_title && g_utf8_validate(utf8_title, -1, NULL)) + title = utf8_title; + else + title = _("title"); + + /* FIXME! we should also add normal bookmark. */ + /* Create New KzBookmark */ + if (strstr(strings[0], "xml") || + strstr(strings[0], "rss") || + strstr(strings[0], "rdf")) + { + bookmark = KZ_BOOKMARK(kz_bookmark_file_new(strings[0], + title, + NULL)); + } + else + { + bookmark = kz_bookmark_new_with_attrs(title, strings[0], NULL); + } + g_strfreev(strings); + if (utf8_title) + g_free(utf8_title); + return bookmark; +} Added: kazehakase/trunk/src/bookmarks/kz-bookmark-utils.h =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark-utils.h 2007-10-04 00:47:49 UTC (rev 3258) +++ kazehakase/trunk/src/bookmarks/kz-bookmark-utils.h 2007-10-04 02:58:48 UTC (rev 3259) @@ -0,0 +1,36 @@ +/* -*- 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. + * + * $Id: kz-bookmark.h 2819 2007-01-20 05:09:01Z kous $ + */ + +#ifndef __KZ_BOOKMARK_UTILS_H__ +#define __KZ_BOOKMARK_UTILS_H__ + +#include "kz-bookmark.h" +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +KzBookmark *kz_bookmark_create_from_selection_data (GtkSelectionData *seldata); + +G_END_DECLS + +#endif /* __KZ_BOOKMARK_UTILS_H__ */