root/trunk/src/DocumentLinkUri.cxx

Revision 197, 2.2 kB (checked in by jordi, 2 years ago)

The URI links now also work, although there's no way yet to change the command line to use from the user's POV.

Line 
1// ePDFView - A lightweight PDF Viewer.
2// Copyright (C) 2006 Emma's Software.
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation; either version 2 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18#include <config.h>
19#include "epdfview.h"
20
21using namespace ePDFView;
22
23///
24/// @brief Construct a new DocumentLinkUri object.
25///
26/// @param x1 The X coordinate of the link's top-left corner.
27/// @param y1 The Y coordinate of the link's top-left corner.
28/// @param x2 The X coordinate of the link's bottom-right corner.
29/// @param y2 The Y coordinate of the link's bottom-right corner.
30/// @param uri The URI the links points to.
31///
32DocumentLinkUri::DocumentLinkUri (gdouble x1, gdouble y1,
33                                  gdouble x2, gdouble y2, const gchar *uri):
34    IDocumentLink (x1, y1, x2, y2)
35{
36    g_assert (NULL != uri && "The URI for the link is NULL.");
37
38    m_Uri = g_strdup (uri);
39}
40
41///
42/// @brief Destroys all dynamically allocated memory by DocumentLinkUri.
43///
44DocumentLinkUri::~DocumentLinkUri ()
45{
46    g_free (m_Uri);
47}
48
49///
50/// @brief Activates the link.
51///
52/// @param document The document where the link was activated from.
53///
54void
55DocumentLinkUri::activate (IDocument *document)
56{
57    // Create the command line to execute the external browser.
58    gchar *userCommandLine =
59        Config::getConfig ().getExternalBrowserCommandLine ();
60    gchar *commandLine = g_strdup_printf (userCommandLine, m_Uri);
61    g_free (userCommandLine);
62    // Call the browser.
63    GError *error = NULL;
64    if ( !g_spawn_command_line_async (commandLine, &error) )
65    {
66        g_error_free (error);
67    }
68    g_free (commandLine);
69}
Note: See TracBrowser for help on using the browser.