diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-05-21 13:17:18 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-05-21 13:31:08 +0100 |
commit | cb0b7ff34dc193c37e89f4a968e1cb7502338230 (patch) | |
tree | 0e5b4d54fd35410ad1e784c38fae584a3dadb5e0 /libreofficekit | |
parent | 5b248f1348260f953686b20621255aece57358fe (diff) |
gtktiledviewer: handle LOK_CALLBACK_SEARCH_NOT_FOUND
Change-Id: Ic545bbd14d11a3b310f4d72ee02e51a7cb6f4f22
Diffstat (limited to 'libreofficekit')
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 14 | ||||
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 21 |
2 files changed, 35 insertions, 0 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 7509b2f98164..d4d010feede2 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -48,6 +48,7 @@ static GtkComboBoxText* pPartSelector; #endif GtkWidget* pFindbar; GtkWidget* pFindbarEntry; +GtkWidget* pFindbarLabel; static LibreOfficeKit* pOffice; @@ -177,6 +178,7 @@ static void signalSearchPrev(GtkWidget* /*pButton*/, gpointer /*pItem*/) /// Handles the key-press-event of the search entry widget. static gboolean signalFindbar(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pData*/) { + gtk_label_set_text(GTK_LABEL(pFindbarLabel), ""); switch(pEvent->keyval) { case GDK_Return: @@ -230,6 +232,12 @@ static void signalCommand(LOKDocView* /*pLOKDocView*/, char* pPayload, gpointer } } +/// LOKDocView found no search matches -> set the search label accordingly. +static void signalSearch(LOKDocView* /*pLOKDocView*/, char* /*pPayload*/, gpointer /*pData*/) +{ + gtk_label_set_text(GTK_LABEL(pFindbarLabel), "Search key not found"); +} + /// User clicked on a cmmand button -> inform LOKDocView. static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/) { @@ -425,12 +433,18 @@ int main( int argc, char* argv[] ) gtk_toolbar_insert(GTK_TOOLBAR(pFindbar), pFindbarPrev, -1); g_signal_connect(G_OBJECT(pFindbarPrev), "clicked", G_CALLBACK(signalSearchPrev), NULL); + GtkToolItem* pFindbarLabelContainer = gtk_tool_item_new(); + pFindbarLabel = gtk_label_new(""); + gtk_container_add(GTK_CONTAINER(pFindbarLabelContainer), pFindbarLabel); + gtk_toolbar_insert(GTK_TOOLBAR(pFindbar), pFindbarLabelContainer, -1); + gtk_box_pack_end(GTK_BOX(pVBox), pFindbar, FALSE, FALSE, 0); // Docview pDocView = lok_docview_new( pOffice ); g_signal_connect(pDocView, "edit-changed", G_CALLBACK(signalEdit), NULL); g_signal_connect(pDocView, "command-changed", G_CALLBACK(signalCommand), NULL); + g_signal_connect(pDocView, "search-not-found", G_CALLBACK(signalSearch), 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 2cbd450a7f62..2e8e24c666d3 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -190,6 +190,8 @@ struct LOKDocView_Impl void globalCallbackWorkerImpl(int nType, const char* pPayload); /// Command state (various buttons like bold are toggled or not) is changed. void commandChanged(const std::string& rPayload); + /// Search did not find any matches. + void searchNotFound(const std::string& rPayload); }; namespace { @@ -1001,6 +1003,9 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback) } break; case LOK_CALLBACK_SEARCH_NOT_FOUND: + { + searchNotFound(pCallback->m_aPayload); + } break; default: g_assert(false); @@ -1045,6 +1050,7 @@ enum { EDIT_CHANGED, COMMAND_CHANGED, + SEARCH_NOT_FOUND, LAST_SIGNAL }; @@ -1055,6 +1061,11 @@ void LOKDocView_Impl::commandChanged(const std::string& rString) g_signal_emit(m_pDocView, docview_signals[COMMAND_CHANGED], 0, rString.c_str()); } +void LOKDocView_Impl::searchNotFound(const std::string& rString) +{ + g_signal_emit(m_pDocView, docview_signals[SEARCH_NOT_FOUND], 0, rString.c_str()); +} + static void lok_docview_class_init( gpointer ptr ) { LOKDocViewClass* pClass = static_cast<LOKDocViewClass *>(ptr); @@ -1079,6 +1090,16 @@ static void lok_docview_class_init( gpointer ptr ) g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); + pClass->search_not_found = 0; + docview_signals[SEARCH_NOT_FOUND] = + g_signal_new("search-not-found", + G_TYPE_FROM_CLASS(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(LOKDocViewClass, search_not_found), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, + G_TYPE_STRING); } static void lok_docview_init( GTypeInstance* pInstance, gpointer ) |