]> git.decadent.org.uk Git - videolink.git/blobdiff - videolink.cpp
Changed informational, warning and error messages to use standard prefixes.
[videolink.git] / videolink.cpp
index 4e9fa6b3c27057a7f64f9ae3b0061f274e3da2c7..b4210a181dbbac5c8c0cf9f2ce95d079ee2becb9 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <stdlib.h>
 
+#include <gdk/gdkkeysyms.h>
 #include <gdkmm/pixbuf.h>
 #include <glibmm/convert.h>
 #include <glibmm/spawn.h>
@@ -120,6 +121,7 @@ namespace
            {".vob",     video_format_mpeg2_ps},
            {".mpeg",    video_format_mpeg2_ps},
            {".mpeg2",   video_format_mpeg2_ps},
+           {".mpg",     video_format_mpeg2_ps},
            {".voblist", video_format_vob_list}
        };
        for (std::size_t i = 0;
@@ -159,7 +161,8 @@ namespace
        add(browser_widget_);
        browser_widget_.show();
 
-       Glib::signal_idle().connect(SigC::slot(*this, &base_window::on_idle));
+       Glib::signal_idle().connect(
+           sigc::mem_fun(this, &base_window::on_idle));
     }
 
     bool base_window::on_idle()
@@ -176,6 +179,7 @@ namespace
 
     private:
        virtual void do_late_initialisation();
+       bool on_key_press(GdkEventKey *);
 
        std::string main_page_uri_;
     };
@@ -185,13 +189,30 @@ namespace
        : base_window(frame_params),
          main_page_uri_(main_page_uri)
     {
+       signal_key_press_event().connect(
+           sigc::mem_fun(this, &preview_window::on_key_press));
     }
 
     void preview_window::do_late_initialisation()
     {
        browser_widget_.load_uri(main_page_uri_);
     }
-    
+
+    bool preview_window::on_key_press(GdkEventKey * event)
+    {
+       switch (event->keyval)
+       {
+       case GDK_t: // = top menu
+           browser_widget_.load_uri(main_page_uri_);
+           return true;
+       case GDK_q: // = quit
+           Gtk::Main::quit();
+           return true;
+       default:
+           return false;
+       }
+    }
+
     class conversion_window : public base_window
     {
     public:
@@ -258,7 +279,7 @@ namespace
          finished_(false)
     {
        browser_widget_.signal_net_state().connect(
-           SigC::slot(*this, &conversion_window::on_net_state_change));
+           sigc::mem_fun(this, &conversion_window::on_net_state_change));
 
        add_menu(main_page_uri);
     }
@@ -322,7 +343,7 @@ namespace
     {
        assert(!page_queue_.empty());
        const std::string & uri = page_queue_.front();
-       std::cout << "loading " << uri << std::endl;
+       std::cout << "INFO: Loading " << uri << std::endl;
 
        browser_widget_.load_uri(uri);
     }
@@ -420,20 +441,18 @@ namespace
            }
            catch (std::exception & e)
            {
-               std::cerr << "Fatal error";
                if (!page_queue_.empty())
-                   std::cerr << " while processing <" << page_queue_.front()
-                             << ">";
-               std::cerr << ": " << e.what() << "\n";
+                   std::cerr << "ERROR: While processing <"
+                             << page_queue_.front() << ">:\n";
+               std::cerr << "ERROR: " << e.what() << "\n";
                Gtk::Main::quit();
            }
            catch (Glib::Exception & e)
            {
-               std::cerr << "Fatal error";
                if (!page_queue_.empty())
-                   std::cerr << " while processing <" << page_queue_.front()
-                             << ">";
-               std::cerr << ": " << e.what() << "\n";
+                   std::cerr << "ERROR: While processing <"
+                             << page_queue_.front() << ">:\n";
+               std::cerr << "ERROR: " << e.what() << "\n";
                Gtk::Main::quit();
            }
        }
@@ -598,7 +617,7 @@ namespace
 
                if (state->link_rect.empty())
                {
-                   std::cerr << "Ignoring invisible link to "
+                   std::cerr << "WARN: Ignoring invisible link to "
                              << uri_and_fragment << "\n";
                    continue;
                }
@@ -614,8 +633,8 @@ namespace
                    check(uri_iface->SchemeIs("file", &is_file));
                    if (!is_file)
                    {
-                       std::cerr << "Links to video must use the file:"
-                                 << " scheme\n";
+                       std::cerr << "WARN: Ignoring non-file link to "
+                                 << uri_and_fragment << "\n";
                        continue;
                    }
                    target = add_title(uri, format);
@@ -776,7 +795,7 @@ namespace
 
 void fatal_error(const std::string & message)
 {
-    std::cerr << "Fatal error: " << message << "\n";
+    std::cerr << "ERROR: " << message << "\n";
     Gtk::Main::quit();
 }
 
@@ -945,7 +964,7 @@ int main(int argc, char ** argv)
        {
            preview_window window(frame_params, menu_url);
            window.show();
-           window.signal_hide().connect(SigC::slot(&Gtk::Main::quit));
+           window.signal_hide().connect(sigc::ptr_fun(Gtk::Main::quit));
            Gtk::Main::run();
            return EXIT_SUCCESS;
        }
@@ -953,14 +972,14 @@ int main(int argc, char ** argv)
        {
            conversion_window window(frame_params, menu_url, output_dir, encoder);
            window.show();
-           window.signal_hide().connect(SigC::slot(&Gtk::Main::quit));
+           window.signal_hide().connect(sigc::ptr_fun(Gtk::Main::quit));
            Gtk::Main::run();
            return window.is_finished() ? EXIT_SUCCESS  : EXIT_FAILURE;
        }
     }
     catch (std::exception & e)
     {
-       std::cerr << "Fatal error: " << e.what() << "\n";
+       std::cerr << "ERROR: " << e.what() << "\n";
        return EXIT_FAILURE;
     }
 }