paperbox r133 - in trunk: . src
- From: markoa svn gnome org
- To: svn-commits-list gnome org
- Subject: paperbox r133 - in trunk: . src
- Date: Sat, 26 Apr 2008 12:21:56 +0100 (BST)
Author: markoa
Date: Sat Apr 26 11:21:56 2008
New Revision: 133
URL: http://svn.gnome.org/viewvc/paperbox?rev=133&view=rev
Log:
Depend on giomm unconditionally
Modified:
trunk/ChangeLog
trunk/README
trunk/configure.ac
trunk/src/category-factory.cc
trunk/src/category.cc
trunk/src/category.hh
trunk/src/file-utils.cc
trunk/src/main.cc
Modified: trunk/README
==============================================================================
--- trunk/README (original)
+++ trunk/README Sat Apr 26 11:21:56 2008
@@ -1,8 +1,8 @@
PaperBox
========
-Metadata-driven document browser for the GNOME desktop
+Document browser for GNOME desktop
-Copyright (C) 2007 Marko Anastasov
+Copyright (C) 2007-2008 Marko Anastasov
Licensed under the GPL, version 2 or greater.
@@ -12,10 +12,10 @@
your documents by tags, which are shared across all Tracker-based applications.
Library requirements:
-* boost C++ libraries
-* tracker 0.6
+* boost C++ library
+* libtracker 0.6
* dbus-glib
-* gio 0.1 - optional, available at http://svn.gnome.org/svn/gio-standalone
+* giomm, part of glibmm 2.16
* libgthread, gtkmm, libglademm, libgnomeui
* gtkmm-utils 0.3, available at http://download.savannah.nongnu.org/releases/gtkmm-utils/
* goocanvas 0.9
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Sat Apr 26 11:21:56 2008
@@ -97,25 +97,14 @@
[],
[AC_MSG_ERROR([Please install boost development headers])])
-AC_CHECK_HEADER([boost/filesystem/fstream.hpp],
- [],
- [AC_MSG_ERROR([*** boost filesystem headers not found!])])
-
-PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.15], [have_gio=yes], [have_gio=no])
-
-if test "$have_gio" = "yes" ; then
- AC_DEFINE(HAVE_GIO, 1, [Define if gio is present])
-fi
-
-AM_CONDITIONAL(HAVE_GIO, test "$have_gio" = "yes")
-
-AC_SUBST([GIO_LIBS])
-AC_SUBST([GIO_CFLAGS])
-
PKG_CHECK_MODULES([GTKMM], [gtkmm-2.4 >= 2.12.0 libglademm-2.4 >= 2.6.0])
AC_SUBST([GTKMM_CFLAGS])
AC_SUBST([GTKMM_LIBS])
+PKG_CHECK_MODULES([GIOMM], [giomm-2.4 >= 2.16.0])
+AC_SUBST([GIOMM_CFLAGS])
+AC_SUBST([GIOMM_LIBS])
+
PKG_CHECK_MODULES([GTKMM_UTILS], [gtkmm-utils >= 0.3.0])
AC_SUBST([GTKMM_UTILS_CFLAGS])
AC_SUBST([GTKMM_UTILS_LIBS])
@@ -132,27 +121,20 @@
AC_SUBST([DBUS_CFLAGS])
AC_SUBST([DBUS_LIBS])
-PKG_CHECK_MODULES([TRACKER], [tracker >= 0.6])
-AC_SUBST([TRACKER_CFLAGS])
-AC_SUBST([TRACKER_LIBS])
-
-AC_HAVE_LIBRARY([pcrecpp], ,
-[echo "Please install libpcre development package with C++ support."; exit 1])
-
-AC_HAVE_LIBRARY(boost_filesystem,
- [AC_SUBST(BOOST_LIBS, [-lboost_filesystem])],
- [AC_MSG_ERROR([*** boost filesystem lib not found!])])
+PKG_CHECK_MODULES([LIBTRACKER], [tracker >= 0.6])
+AC_SUBST([LIBTRACKER_CFLAGS])
+AC_SUBST([LIBTRACKER_LIBS])
# *************************************
# LIBS and CFLAGS definitions
# *************************************
-PAPERBOX_LIBS="$GIO_LIBS $GTHREAD_LIBS $GTKMM_LIBS $GTKMM_UTILS_LIBS \
- $LIBGNOMEUI_LIBS $GOOCANVAS_LIBS $DBUS_LIBS $TRACKER_LIBS $BOOST_LIBS"
+PAPERBOX_LIBS="$GTHREAD_LIBS $GTKMM_LIBS $GIOMM_LIBS $GTKMM_UTILS_LIBS \
+ $LIBGNOMEUI_LIBS $GOOCANVAS_LIBS $DBUS_LIBS $LIBTRACKER_LIBS"
-PAPERBOX_CFLAGS="$GIO_CFLAGS $GTHREAD_CFLAGS $GTKMM_CFLAGS \
+PAPERBOX_CFLAGS="$GTHREAD_CFLAGS $GTKMM_CFLAGS $GIOMM_CFLAGS \
$GTKMM_UTILS_CFLAGS $LIBGNOMEUI_CFLAGS $GOOCANVAS_CFLAGS \
- $DBUS_CFLAGS $TRACKER_CFLAGS"
+ $DBUS_CFLAGS $LIBTRACKER_CFLAGS"
AC_SUBST(PAPERBOX_LIBS)
AC_SUBST(PAPERBOX_CFLAGS)
Modified: trunk/src/category-factory.cc
==============================================================================
--- trunk/src/category-factory.cc (original)
+++ trunk/src/category-factory.cc Sat Apr 26 11:21:56 2008
@@ -21,18 +21,16 @@
*/
#include <list>
-#include <boost/filesystem.hpp>
#include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
#include <glibmm/stringutils.h>
#include <glibmm-utils/log-stream-utils.h>
#include <glibmm-utils/ustring.h>
+#include <giomm/file.h>
#include "category-factory.hh"
namespace paperbox {
- namespace bfs = boost::filesystem;
-
using std::list;
using std::string;
using boost::shared_ptr;
@@ -75,14 +73,11 @@
throw CategoryNotFound(
Glib::Util::uprintf("category %s not found", name.c_str()));
- bfs::path path(Category::get_default_path() + name);
+ Glib::RefPtr<Gio::File> file =
+ Gio::File::create_for_path(Category::get_default_path() + name);
- try {
- bfs::remove(path);
- } catch (const bfs::filesystem_error& ex) {
- LOG_EXCEPTION("Unable to remove category file "
- << path.string() << ": "
- << ex.what());
+ if (! file->remove()) {
+ LOG_ERROR("Unable to remove category file " << file->get_path());
}
}
Modified: trunk/src/category.cc
==============================================================================
--- trunk/src/category.cc (original)
+++ trunk/src/category.cc Sat Apr 26 11:21:56 2008
@@ -24,9 +24,9 @@
#include <glib/gstdio.h>
#include <fstream>
#include <iostream>
-#include <boost/filesystem/fstream.hpp>
#include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
+#include <glibmm-utils/log-stream-utils.h>
#include "category.hh"
namespace {
@@ -73,32 +73,25 @@
namespace paperbox {
- namespace bfs = boost::filesystem;
-
using std::string;
using std::vector;
- using bfs::exists;
- using bfs::fstream;
- using bfs::ofstream;
- using bfs::path;
-
// Checks for the main category directory, creates an empty file
// if no previous data is present.
Category::Category(const Glib::ustring& name)
:
- name_(name.raw()),
- path_(get_default_path() + name.raw())
+ name_(name.raw())
{
+ file_ = Gio::File::create_for_path(get_default_path() + name_);
check_category_path();
- if (! exists(path_)) {
+ if (! file_->query_exists()) {
// touch
- ofstream empty_stream(path_);
- empty_stream.close();
+ Glib::RefPtr<Gio::FileOutputStream> os = file_->create_file();
+ os->close();
} else {
// load tags
- std::ifstream ifs(path_.string().c_str());
+ std::ifstream ifs(file_->get_path().c_str());
read_lines(ifs, tags_);
}
}
@@ -110,11 +103,11 @@
bool
Category::add_tag(const Glib::ustring& tag)
{
- std::ifstream ifs(path_.string().c_str());
+ std::ifstream ifs(file_->get_path().c_str());
if (! ifs.is_open()) {
g_warning("Unable to open category file %s to add tag",
- path_.string().c_str());
+ file_->get_path().c_str());
return false;
}
@@ -127,35 +120,43 @@
return false;
}
- using std::ios_base;
- bfs::ofstream fs(path_, ios_base::app | ios_base::ate | ios_base::out);
- fs << tag << std::endl;
- fs.close();
+ Glib::RefPtr<Gio::FileOutputStream> stream = file_->append_to();
+ stream->write(tag + '\n');
+ if (! stream->close())
+ LOG_ERROR("could not close stream for category file "
+ << file_->get_path());
+
return true;
}
void
Category::reset_tags(const vector<Glib::ustring>& new_tags)
{
- using std::ios_base;
- bfs::ofstream fs(path_, ios_base::out | ios_base::trunc);
+ Glib::RefPtr<Gio::FileOutputStream> stream;
+
+ if (file_->query_exists())
+ stream = file_->replace();
+ else
+ stream = file_->create_file();
vector<Glib::ustring>::const_iterator it(new_tags.begin());
vector<Glib::ustring>::const_iterator end(new_tags.end());
for ( ; it != end; ++it)
- fs << *it << std::endl;
+ stream->write(*it + "\n");
- fs.close();
+ if (! stream->close())
+ LOG_ERROR("could not close stream for category file "
+ << file_->get_path());
}
bool
Category::remove_tag(const Glib::ustring& tag)
{
- std::ifstream ifs(path_.string().c_str());
+ std::ifstream ifs(file_->get_path().c_str());
if (! ifs.is_open()) {
g_warning("Unable to open category file %s to remove tag",
- path_.string().c_str());
+ file_->get_path().c_str());
return false;
}
@@ -171,15 +172,17 @@
tags.erase(remove(tags.begin(), tags.end(), tag.raw()), tags.end());
// rewrite the file with remaining tags
- bfs::ofstream fs(path_);
+ Glib::RefPtr<Gio::FileOutputStream> stream = file_->replace();
vector<string>::iterator it(tags.begin());
vector<string>::iterator end(tags.end());
- for ( ; it != end; ++it) {
- fs << *it << std::endl;
- }
+ for ( ; it != end; ++it)
+ stream->write(*it + "\n");
+
+ if (! stream->close())
+ LOG_ERROR("could not close stream for category file "
+ << file_->get_path());
- fs.close();
return true;
}
Modified: trunk/src/category.hh
==============================================================================
--- trunk/src/category.hh (original)
+++ trunk/src/category.hh Sat Apr 26 11:21:56 2008
@@ -25,9 +25,9 @@
#include <string>
#include <vector>
-#include <boost/filesystem.hpp>
#include <boost/noncopyable.hpp>
#include <glibmm/ustring.h>
+#include <giomm/file.h>
namespace paperbox {
@@ -51,7 +51,7 @@
protected:
std::string name_;
- boost::filesystem::path path_;
+ Glib::RefPtr<Gio::File> file_;
std::vector<Glib::ustring> tags_;
};
Modified: trunk/src/file-utils.cc
==============================================================================
--- trunk/src/file-utils.cc (original)
+++ trunk/src/file-utils.cc Sat Apr 26 11:21:56 2008
@@ -20,19 +20,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <config.h>
-
#include <glib.h>
-
-#ifdef HAVE_GIO
#include <gio/gio.h>
-#else
-#include <libgnomevfs/gnome-vfs-file-info.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <glibmm-utils/date.h>
-#endif // HAVE_GIO
-
#include <glibmm/convert.h>
+#include <glibmm-utils/log-stream-utils.h>
#include "file-utils.hh"
namespace paperbox {
@@ -48,7 +39,7 @@
result = g_spawn_command_line_async (command, NULL);
g_free (command);
- return result;
+ return result;
}
void
@@ -56,7 +47,6 @@
guint64& modtime,
Glib::ustring& modtime_string)
{
-#ifdef HAVE_GIO
GFile* file;
GFileQueryInfoFlags flags;
GFileInfo* info;
@@ -71,7 +61,7 @@
&error);
if (info == NULL) {
- g_printerr ("Error getting time info: %s\n", error->message);
+ LOG_ERROR("couldn't gett time info: %s\n" << error->message);
g_error_free (error);
}
@@ -86,25 +76,6 @@
strftime(time_string, sizeof(time_string), "%c", ptm);
modtime_string = Glib::locale_to_utf8(time_string);
-#else
- GnomeVFSFileInfo* info = NULL;
- GnomeVFSResult result;
-
- info = gnome_vfs_file_info_new();
- result = gnome_vfs_get_file_info (uri.c_str(),
- info,
- GNOME_VFS_FILE_INFO_DEFAULT);
-
- if (result == GNOME_VFS_OK) {
- modtime = info->mtime;
- Glib::Util::get_modification_date(info->mtime, modtime_string);
- } else
- g_warning("no file info for %s: %s",
- uri.c_str(),
- gnome_vfs_result_to_string (result));
-
- gnome_vfs_file_info_unref(info);
-#endif // HAVE_GIO
}
} // namespace paperbox
Modified: trunk/src/main.cc
==============================================================================
--- trunk/src/main.cc (original)
+++ trunk/src/main.cc Sat Apr 26 11:21:56 2008
@@ -21,6 +21,7 @@
*/
#include <iostream>
+#include <giomm/init.h>
#include <gtkmm/main.h>
#include <glibmm-utils/log-stream-utils.h>
#include "main-window.hh"
@@ -29,6 +30,7 @@
main(int argc, char** argv)
{
Glib::thread_init(); // libgnomeui requires it
+ Gio::init();
Gtk::Main kit(argc, argv);
paperbox::MainWindow* main_window = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]