Kaydet (Commit) 9d2fa921 authored tarafından Pranav Kant's avatar Pranav Kant Kaydeden (comit) Miklos Vajna

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
üst 1584b6e8
......@@ -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);
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment