[gnote] refactor open_url()



commit 461abe4bb97fcbe0f699efa13bbdabaa0a69a3c3
Author: Hubert Figuiere <hub figuiere net>
Date:   Sat Apr 25 21:48:37 2009 -0400

    refactor open_url()
---
 src/utils.cpp    |   15 +++++++++++++++
 src/utils.hpp    |    1 +
 src/watchers.cpp |   15 +--------------
 src/watchers.hpp |    1 -
 4 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/src/utils.cpp b/src/utils.cpp
index 5df8ee0..f5147e0 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -142,6 +142,21 @@ namespace gnote {
       }
     }
 
+
+    void open_url(const std::string & url)
+      throw (Glib::Error)
+    {
+      if(!url.empty()) {
+        GError *err = NULL;
+        DBG_OUT("Opening url '%s'...", url.c_str());
+        gtk_show_uri (NULL, url.c_str(), GDK_CURRENT_TIME, &err);
+        if(err) {
+          throw Glib::Error(err, true);
+        }
+      }
+    }
+
+
     void show_opening_location_error(Gtk::Window * parent, 
                                      const std::string & url, 
                                      const std::string & error)
diff --git a/src/utils.hpp b/src/utils.hpp
index b240690..605578e 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -54,6 +54,7 @@ namespace gnote {
 
     void show_help(const std::string & filename, const std::string & link_id,
                    GdkScreen *screen, Gtk::Window *parent);
+    void open_url(const std::string & url) throw (Glib::Error);
     void show_opening_location_error(Gtk::Window * parent, 
                                      const std::string & url, 
                                      const std::string & error);
diff --git a/src/watchers.cpp b/src/watchers.cpp
index a585b1e..d5a1aa4 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -481,19 +481,6 @@ namespace gnote {
     return url;
   }
 
-  void NoteUrlWatcher::open_url(const std::string & url)
-    throw (Glib::Error)
-  {
-    if(!url.empty()) {
-      GError *err = NULL;
-      DBG_OUT("Opening url '%s'...", url.c_str());
-      gtk_show_uri (NULL, url.c_str(), GDK_CURRENT_TIME, &err);
-      if(err) {
-        throw Glib::Error(err, true);
-      }
-    }
-  }
-
 
   bool NoteUrlWatcher::on_url_tag_activated(const NoteTag::Ptr &, const NoteEditor &,
                               const Gtk::TextIter & start, const Gtk::TextIter & end)
@@ -501,7 +488,7 @@ namespace gnote {
   {
     std::string url = get_url (start, end);
     try {
-      open_url (url);
+      utils::open_url (url);
     } 
     catch (Glib::Error & e) {
       utils::show_opening_location_error (get_window(), url, e.what());
diff --git a/src/watchers.hpp b/src/watchers.hpp
index 48138a3..be03b24 100644
--- a/src/watchers.hpp
+++ b/src/watchers.hpp
@@ -142,7 +142,6 @@ namespace gnote {
     NoteUrlWatcher();
   private:
     std::string get_url(const Gtk::TextIter & start, const Gtk::TextIter & end);
-    void open_url(const std::string & url) throw (Glib::Error);
     bool on_url_tag_activated(const NoteTag::Ptr &, const NoteEditor &,
                               const Gtk::TextIter &, const Gtk::TextIter &);
     void apply_url_to_block (Gtk::TextIter start, Gtk::TextIter end);



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