diff options
author | Pranav Kant <pranavk@gnome.org> | 2015-06-23 01:52:44 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-06-29 13:33:35 +0200 |
commit | 9d2fa921470152647cc3b54355f70a1365f752ff (patch) | |
tree | a1cd0e876bfc44a019a7323fb95bc9066d816e26 /libreofficekit | |
parent | 1584b6e876a26f701c93fdf03f4f1200058a13cb (diff) |
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
Diffstat (limited to 'libreofficekit')
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 12 | ||||
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 11 |
2 files changed, 20 insertions, 3 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 917b2947434c..1ca9454df4ba 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -312,6 +312,17 @@ static void signalPart(LOKDocView* /*pLOKDocView*/, int nPart, gpointer /*pData* } /// User clicked on a command button -> inform LOKDocView. +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); + } +} + static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/) { if (g_bToolItemBroadcast) @@ -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 cff02ea7fea0..988397a307be 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, |