[Libreoffice-commits] core.git: include/LibreOfficeKit libreofficekit/qa libreofficekit/source

Miklos Vajna vmiklos at collabora.co.uk
Thu May 21 05:31:50 PDT 2015


 include/LibreOfficeKit/LibreOfficeKitGtk.h          |    1 
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |   14 +++++++++++++
 libreofficekit/source/gtk/lokdocview.cxx            |   21 ++++++++++++++++++++
 3 files changed, 36 insertions(+)

New commits:
commit cb0b7ff34dc193c37e89f4a968e1cb7502338230
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu May 21 13:17:18 2015 +0100

    gtktiledviewer: handle LOK_CALLBACK_SEARCH_NOT_FOUND
    
    Change-Id: Ic545bbd14d11a3b310f4d72ee02e51a7cb6f4f22

diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index a517fca..cce580f 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -39,6 +39,7 @@ struct _LOKDocViewClass
   GtkScrolledWindowClass parent_class;
   void (* edit_changed)  (LOKDocView* pView, gboolean was_edit);
   void (* command_changed) (LOKDocView* pView, char* new_state);
+  void (* search_not_found) (LOKDocView* pView, char* new_state);
 };
 
 guint           lok_docview_get_type        (void);
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 7509b2f..d4d010f 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 2cbd450..2e8e24c 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 )


More information about the Libreoffice-commits mailing list