[nemiver] Removed gnome-vfs compat code



commit 9ba154eb7dffe9376c618546d64ee05f86179e34
Author: Kalev Lember <kalevlember gmail com>
Date:   Wed Mar 23 18:44:19 2011 +0200

    Removed gnome-vfs compat code
    
    	Drop gnome-vfs compat code, useless for GTK+ >= 2.22
    	* configure.ac: Removed checks for gnome-vfs-2.0 and WITH_GIO
    	define.
    	* src/persp/dbgperspective/nmv-dbg-perspective.cc
    	(gio_file_monitor_cb): Remove WITH_GIO ifdef around this, making
    	it declared/defined unconditionally.
    	(gnome_vfs_file_monitor_cb): Remove this declaration/definition.
    	(DBGPerspective::Priv::Path2MonitorMap): Only keep the WITH_GIO
    	version.  Drop the ifdef.
    	(DBGPerspective::do_monitor_file)
    	(DBGPerspective::do_unmonitor_file): Unconditionally keep the
    	#ifdef WITH_GIO parts.  Drop the ifdef.
    	* src/uicommon/nmv-source-editor.cc
    	(SourceEditor::get_file_mime_type, SourceEditor::load_file): Likewise.
    	* src/workbench/nmv-workbench.cc
    	(WorkbenchStaticInit::WorkbenchStaticInit): Likewise.

 configure.ac                                    |   21 +----
 src/persp/dbgperspective/nmv-dbg-perspective.cc |  104 +----------------------
 src/uicommon/nmv-source-editor.cc               |   36 +-------
 src/workbench/nmv-workbench.cc                  |   11 ---
 4 files changed, 6 insertions(+), 166 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a89df2c..90e3e43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,8 +42,6 @@ LIBGTHREAD_VERSION=2.14
 AC_SUBST([LIBGTHREAD_VERSION])
 LIBGLIBMM_VERSION=2.14
 AC_SUBST([LIBGLIBMM_VERSION])
-LIBGNOMEVFS_VERSION=2.14
-AC_SUBST([LIBGNOMEVFS_VERSION])
 LIBXML2_VERSION=2.6.22
 AC_SUBST([LIBXML2_VERSION])
 LIBGTK_VERSION=2.22
@@ -197,22 +195,6 @@ else
     LIBGTKSOURCEVIEWMM_PKG=libgtksourceviewmm-1.0
 fi
 
-AC_ARG_ENABLE(gio,
-              AS_HELP_STRING([--enable-gio=yes|no],
-                             [use gio instead of gnomevfs (default is auto)]),
-              ENABLE_GIO=$enableval,
-              [PKG_CHECK_EXISTS([giomm-2.4 >= $LIBGIOMM_VERSION], [ENABLE_GIO=yes], [ENABLE_GIO=no])])
-if test x$ENABLE_GIO = xyes ; then
-    AC_DEFINE([WITH_GIO], 1, [build with gio instead of gnomevfs])
-    VFS_PKG=giomm-2.4
-    VFS_VERSION=$LIBGIOMM_VERSION
-else
-    VFS_PKG=gnome-vfs-2.0
-    VFS_VERSION=$LIBGNOMEVFS_VERSION
-    ENABLE_GIO=no
-fi
-DEP_VFS="$VFS_PKG >= $VFS_VERSION"
-
 ENABLE_DEBUG=yes
 AC_ARG_ENABLE(debug,
               AS_HELP_STRING([--enable-debug=yes|no],
@@ -314,6 +296,8 @@ NEMIVERUICOMMON_LIBS="$NEMIVERUICOMMON_LIBS $CPPUNIT_LIBS"
 AC_SUBST(NEMIVERUICOMMON_LIBS)
 AC_SUBST(NEMIVERUICOMMON_CFLAGS)
 
+DEP_VFS="giomm-2.4 >= $LIBGIOMM_VERSION"
+
 dnl library dependencies for the nemiver workbench module
 dnl dependencies list already declared above
 
@@ -485,7 +469,6 @@ AC_MSG_NOTICE([
     Enable workbench                : ${ENABLE_WORKBENCH}
     Enable memory view              : ${ENABLE_MEMORYVIEW} (requires gtkhex > $GTKHEX_VERSION)
     gtksourceviewmm version         : ${LIBGTKSOURCEVIEWMM_PKG}
-    VFS library                     : ${VFS_PKG}
     Enable symbols visibility ctrl  : ${ENABLE_GCC_SYMBOLS_VISIBILITY}
     Maintainer mode                 : ${USER_MAINTAINER_MODE}
 
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index 9469293..86e93a4 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -35,15 +35,8 @@
 #include <sstream>
 #include <glib/gi18n.h>
 
-#ifdef WITH_GIO
 #include <giomm/file.h>
 #include <giomm/contenttype.h>
-#else
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
-#include <libgnomevfs/gnome-vfs-monitor.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#endif // WITH_GIO
 
 #include <gtksourceviewmm/init.h>
 #ifdef WITH_SOURCEVIEWMM2
@@ -147,21 +140,11 @@ const char *PROG_ARG_SEPARATOR = "#DUMMY-SEP007#";
 
 class DBGPerspective;
 
-#ifdef WITH_GIO
 static void
 gio_file_monitor_cb (const Glib::RefPtr<Gio::File>& file,
                      const Glib::RefPtr<Gio::File>& other_file,
                      Gio::FileMonitorEvent event,
                      DBGPerspective *a_persp);
-#else
-static void
-gnome_vfs_file_monitor_cb (GnomeVFSMonitorHandle *a_handle,
-                           const gchar *a_monitor_uri,
-                           const gchar *a_info_uri,
-                           GnomeVFSMonitorEventType a_event_type,
-                           DBGPerspective *a_persp);
-#endif
-
 
 class DBGPerspective : public IDBGPerspective, public sigc::trackable {
     //non copyable
@@ -170,18 +153,10 @@ class DBGPerspective : public IDBGPerspective, public sigc::trackable {
     struct Priv;
     SafePtr<Priv> m_priv;
 
-#ifdef WITH_GIO
     friend void gio_file_monitor_cb (const Glib::RefPtr<Gio::File>& a_f,
                                      const Glib::RefPtr<Gio::File>& a_f2,
                                      Gio::FileMonitorEvent event,
                                      DBGPerspective *a_persp);
-#else
-    friend void gnome_vfs_file_monitor_cb (GnomeVFSMonitorHandle *a_handle,
-                                           const gchar *a_monitor_uri,
-                                           const gchar *a_info_uri,
-                                           GnomeVFSMonitorEventType a_et,
-                                           DBGPerspective *a_persp);
-#endif
 
 private:
 
@@ -850,20 +825,11 @@ struct UnrefGObjectNative {
     }
 };
 
-#ifdef WITH_GIO
 static
 void gio_file_monitor_cb (const Glib::RefPtr<Gio::File>& file,
                           const Glib::RefPtr<Gio::File>& other_file,
                           Gio::FileMonitorEvent event,
                           DBGPerspective *a_persp);
-#else
-static
-void gnome_vfs_file_monitor_cb (GnomeVFSMonitorHandle *a_handle,
-                      const gchar *a_monitor_uri,
-                      const gchar *a_info_uri,
-                      GnomeVFSMonitorEventType a_event_type,
-                      DBGPerspective *a_persp);
-#endif // WITH_GIO
 
 struct DBGPerspective::Priv {
     bool initialized;
@@ -936,11 +902,7 @@ struct DBGPerspective::Priv {
     map<UString, int> basename_2_pagenum_map;
     map<int, SourceEditor*> pagenum_2_source_editor_map;
     map<int, UString> pagenum_2_path_map;
-#ifdef WITH_GIO
     typedef map<UString, Glib::RefPtr<Gio::FileMonitor> > Path2MonitorMap;
-#else
-    typedef map<UString, GnomeVFSMonitorHandle*> Path2MonitorMap;
-#endif // WITH_GIO
     Path2MonitorMap path_2_monitor_map;
     Gtk::Notebook *statuses_notebook;
     SafePtr<LocalVarsInspector> variables_editor;
@@ -1238,7 +1200,6 @@ enum ViewsIndex
 #define CHECK_P_INIT THROW_IF_FAIL(m_priv && m_priv->initialized);
 #endif
 
-#ifdef WITH_GIO
 static void
 gio_file_monitor_cb (const Glib::RefPtr<Gio::File>& file,
                      const Glib::RefPtr<Gio::File>& other_file,
@@ -1262,42 +1223,6 @@ gio_file_monitor_cb (const Glib::RefPtr<Gio::File>& file,
     }
     NEMIVER_CATCH
 }
-#else
-static void
-gnome_vfs_file_monitor_cb (GnomeVFSMonitorHandle *a_handle,
-                           const gchar *a_monitor_uri,
-                           const gchar *a_info_uri,
-                           GnomeVFSMonitorEventType a_event_type,
-                           DBGPerspective *a_persp)
-{
-    LOG_FUNCTION_SCOPE_NORMAL_DD;
-
-    RETURN_IF_FAIL (a_info_uri);
-
-    NEMIVER_TRY
-
-    if (a_handle) {}
-
-    LOG_DD ("monitor_uri: " << a_monitor_uri << "\n"
-         "info_uri: " << a_info_uri);
-
-    if (a_event_type == GNOME_VFS_MONITOR_EVENT_CHANGED) {
-        LOG_DD ("file content changed");
-        GnomeVFSURI *uri = gnome_vfs_uri_new (a_info_uri);
-        if (gnome_vfs_uri_get_path (uri)) {
-            UString path = Glib::filename_to_utf8
-                                            (gnome_vfs_uri_get_path (uri));
-            Glib::signal_idle ().connect
-                (sigc::bind
-                    (sigc::mem_fun (*a_persp,
-                                    &DBGPerspective::on_file_content_changed),
-                     path));
-        }
-        gnome_vfs_uri_unref (uri);
-    }
-    NEMIVER_CATCH
-}
-#endif // WITH_GIO
 
 ostream&
 operator<< (ostream &a_out,
@@ -4831,7 +4756,6 @@ DBGPerspective::do_monitor_file (const UString &a_path)
 {
     THROW_IF_FAIL (m_priv);
 
-#ifdef WITH_GIO
     if (m_priv->path_2_monitor_map.find (a_path) !=
         m_priv->path_2_monitor_map.end ()) {
         return false;
@@ -4844,29 +4768,7 @@ DBGPerspective::do_monitor_file (const UString &a_path)
     monitor->signal_changed (). connect (sigc::bind (sigc::ptr_fun
                 (gio_file_monitor_cb), this));
     m_priv->path_2_monitor_map[a_path] = monitor;
-#else
-    if (m_priv->path_2_monitor_map.find (a_path) !=
-        m_priv->path_2_monitor_map.end ()) {
-        return false;
-    }
-    GnomeVFSMonitorHandle *handle=0;
-    GCharSafePtr uri (gnome_vfs_get_uri_from_local_path (a_path.c_str ()));
-    GnomeVFSResult result = gnome_vfs_monitor_add
-                        (&handle, uri.get (),
-                         GNOME_VFS_MONITOR_FILE,
-                         (GnomeVFSMonitorCallback)gnome_vfs_file_monitor_cb,
-                         (gpointer)this);
-    if (result != GNOME_VFS_OK) {
-        LOG_ERROR ("failed to start monitoring file '" << a_path << "'");
-        if (handle) {
-            gnome_vfs_monitor_cancel (handle);
-            handle = 0;
-        }
-        return false;
-    }
-    THROW_IF_FAIL (handle);
-    m_priv->path_2_monitor_map[a_path] = handle;
-#endif // WITH_GIO
+
     LOG_DD ("Monitoring file '" << Glib::filename_from_utf8 (a_path));
     return true;
 }
@@ -4888,11 +4790,7 @@ DBGPerspective::do_unmonitor_file (const UString &a_path)
         return false;
     }
     if (it->second) {
-#ifdef WITH_GIO
         it->second->cancel ();
-#else
-        gnome_vfs_monitor_cancel (it->second);
-#endif // WITH_GIO
     }
     m_priv->path_2_monitor_map.erase (it);
     return true;
diff --git a/src/uicommon/nmv-source-editor.cc b/src/uicommon/nmv-source-editor.cc
index 4cc294b..2931af1 100644
--- a/src/uicommon/nmv-source-editor.cc
+++ b/src/uicommon/nmv-source-editor.cc
@@ -36,15 +36,8 @@
 #else
 #include <gtksourceviewmm/sourcelanguagesmanager.h>
 #endif  // WITH_SOURCEVIEWMM2
-#ifdef WITH_GIO
 #include <giomm/file.h>
 #include <giomm/contenttype.h>
-#else
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
-#include <libgnomevfs/gnome-vfs-monitor.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#endif // WITH_GIO
 #include "common/nmv-exception.h"
 #include "common/nmv-sequence.h"
 #include "common/nmv-str-utils.h"
@@ -1279,20 +1272,12 @@ SourceEditor::get_file_mime_type (const UString &a_path,
 
     std::string path = Glib::filename_from_utf8 (a_path);
 
-#ifdef WITH_GIO
     Glib::RefPtr<Gio::File> gio_file = Gio::File::create_for_path (path);
     THROW_IF_FAIL (gio_file);
-#else
-    UString base_name = Glib::filename_to_utf8 (Glib::path_get_basename (path));
-#endif
 
     UString mime_type;
-#ifdef WITH_GIO
     Glib::RefPtr<Gio::FileInfo> info = gio_file->query_info();
     mime_type = Gio::content_type_get_mime_type(info->get_content_type ());
-#else
-    mime_type = gnome_vfs_get_mime_type_for_name (base_name.c_str ());
-#endif
 
     if (mime_type == "") {
         mime_type = "text/x-c++";
@@ -1379,16 +1364,10 @@ SourceEditor::load_file (const UString &a_path,
     NEMIVER_TRY;
 
     std::string path = Glib::filename_from_utf8 (a_path);
-#ifdef WITH_GIO
     Glib::RefPtr<Gio::File> gio_file = Gio::File::create_for_path (path);
     THROW_IF_FAIL (gio_file);
-    #define FILE_IS_OK (!gio_file->query_exists ())
-#else
-    ifstream file (path.c_str ());
-    #define FILE_IS_OK (!file.good () && !file.eof ())
 
-#endif
-    if (FILE_IS_OK) {
+    if (!gio_file->query_exists ()) {
         LOG_ERROR ("Could not open file " + path);
         ui_utils::display_error ("Could not open file: "
                                  + Glib::filename_to_utf8 (path));
@@ -1413,7 +1392,7 @@ SourceEditor::load_file (const UString &a_path,
 
     unsigned nb_bytes=0;
     std::string content;
-#ifdef WITH_GIO
+
     Glib::RefPtr<Gio::FileInputStream> gio_stream = gio_file->read ();
     THROW_IF_FAIL (gio_stream);
     gssize bytes_read = 0;
@@ -1424,16 +1403,7 @@ SourceEditor::load_file (const UString &a_path,
         if (bytes_read != buf_size) {break;}
     }
     gio_stream->close ();
-#else
-    for (;;) {
-        file.read (buf.get (), buf_size);
-        content.append (buf.get (), file.gcount ());
-        THROW_IF_FAIL (file.good () || file.eof ());
-        nb_bytes += file.gcount ();
-        if (file.gcount () != buf_size) {break;}
-    }
-    file.close ();
-#endif // WITH_GIO
+
     UString utf8_content;
     std::string cur_charset;
     if (!str_utils::ensure_buffer_is_in_utf8 (content,
diff --git a/src/workbench/nmv-workbench.cc b/src/workbench/nmv-workbench.cc
index 733d6a6..73444ba 100644
--- a/src/workbench/nmv-workbench.cc
+++ b/src/workbench/nmv-workbench.cc
@@ -27,11 +27,7 @@
 #include <vector>
 #include <iostream>
 #include <glib/gi18n.h>
-#ifdef WITH_GIO
 #include <giomm/init.h>
-#else
-#include <libgnomevfs/gnome-vfs-init.h>
-#endif // WITH_GIO
 #include <gtkmm/aboutdialog.h>
 #include <gtkmm/icontheme.h>
 #include "common/nmv-exception.h"
@@ -72,18 +68,11 @@ static const UString CONF_KEY_NEMIVER_WINDOW_MINIMUM_HEIGHT=
 class WorkbenchStaticInit {
     WorkbenchStaticInit ()
     {
-#ifdef WITH_GIO
         Gio::init();
-#else
-        gnome_vfs_init ();
-#endif // WITH_GIO
     }
 
     ~WorkbenchStaticInit ()
     {
-#ifndef WITH_GIO
-        gnome_vfs_shutdown ();
-#endif  // WITH_GIO
     }
 
 public:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]