[Libreoffice-commits] core.git: Branch 'feature/gsoc-tiled-rendering' - libreofficekit/qa libreofficekit/source
Pranav Kant
pranavk at gnome.org
Mon Jun 22 13:25:40 PDT 2015
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 12 ++++++++++++
libreofficekit/source/gtk/lokdocview.cxx | 11 ++++++++---
2 files changed, 20 insertions(+), 3 deletions(-)
New commits:
commit 3b7bc09f1554d4ae6d03704ac621e58f09fbb6b3
Author: Pranav Kant <pranavk at gnome.org>
Date: Tue Jun 23 01:52:44 2015 +0530
lokdocview: Don't handle hyperlink clicks
Instead emit the signal 'hyperlink-clicked', and let the
application decide how it wants to handle the hyperlink clicks.
Change-Id: Ief72bbd16727e140cacf28b852ad43952c02f7ae
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index a583323..c854288 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -311,6 +311,17 @@ static void signalPart(LOKDocView* /*pLOKDocView*/, int nPart, gpointer /*pData*
g_bPartSelectorBroadcast = true;
}
+static void signalHyperlink(LOKDocView* /*pLOKDocView*/, char* pPayload, gpointer /*pData*/)
+{
+ GError* pError = NULL;
+ gtk_show_uri(NULL, pPayload, GDK_CURRENT_TIME, &pError);
+ if (pError != NULL)
+ {
+ g_warning("Unable to show URI %s : %s", pPayload, pError->message);
+ g_error_free(pError);
+ }
+}
+
/// User clicked on a cmmand button -> inform LOKDocView.
static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/)
{
@@ -528,6 +539,7 @@ int main( int argc, char* argv[] )
g_signal_connect(pDocView, "command-changed", G_CALLBACK(signalCommand), NULL);
g_signal_connect(pDocView, "search-not-found", G_CALLBACK(signalSearch), NULL);
g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), NULL);
+ g_signal_connect(pDocView, "hyperlink-clicked", G_CALLBACK(signalHyperlink), NULL);
// Input handling.
g_signal_connect(pWindow, "key-press-event", G_CALLBACK(signalKey), pDocView);
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index cff02ea..988397a 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -324,6 +324,12 @@ setPart(LOKDocView* pDocView, const std::string& rString)
g_signal_emit(pDocView, doc_view_signals[PART_CHANGED], 0, std::stoi(rString));
}
+static void
+hyperlinkClicked(LOKDocView* pDocView, const std::string& rString)
+{
+ g_signal_emit(pDocView, doc_view_signals[HYPERLINK_CLICKED], 0, rString.c_str());
+}
+
/// Implementation of the global callback handler, invoked by globalCallback();
static gboolean
globalCallback (gpointer pData)
@@ -507,8 +513,7 @@ callback (gpointer pData)
break;
case LOK_CALLBACK_HYPERLINK_CLICKED:
{
- GError* pError = NULL;
- gtk_show_uri(NULL, pCallback->m_aPayload.c_str(), GDK_CURRENT_TIME, &pError);
+ hyperlinkClicked(pDocView, pCallback->m_aPayload);
}
break;
case LOK_CALLBACK_STATE_CHANGED:
@@ -1353,7 +1358,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
* @aHyperlink: the URI which the application should handle
*/
doc_view_signals[HYPERLINK_CLICKED] =
- g_signal_new("hyperlinked-clicked",
+ g_signal_new("hyperlink-clicked",
G_TYPE_FROM_CLASS(pGObjectClass),
G_SIGNAL_RUN_FIRST,
0,
More information about the Libreoffice-commits
mailing list