diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-05-27 11:30:04 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-05-27 11:48:53 +0200 |
commit | c7ecbbbb6acf92af4ded4119da6abdddace39fe0 (patch) | |
tree | fb54dcda25b52d058df15284a20020d2726714f3 /libreofficekit | |
parent | adce9bf3ad0f12490fc3c8ae429045579642886c (diff) |
lokdocview: fix not updated part selector when search changes part
Change-Id: I337eed47c56dbbbebda4d7fe716eab6177936dc0
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, 33 insertions, 2 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 188d66251dc5..5fbd3374a843 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -45,6 +45,8 @@ static GtkWidget* pVBox; // GtkComboBox requires gtk 2.24 or later #if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2 static GtkComboBoxText* pPartSelector; +/// Should the part selector avoid calling lok::Document::setPart()? +static bool g_bPartSelectorBroadcast = true; #endif GtkWidget* pFindbar; GtkWidget* pFindbarEntry; @@ -238,6 +240,15 @@ static void signalSearch(LOKDocView* /*pLOKDocView*/, char* /*pPayload*/, gpoint gtk_label_set_text(GTK_LABEL(pFindbarLabel), "Search key not found"); } +static void signalPart(LOKDocView* /*pLOKDocView*/, int nPart, gpointer /*pData*/) +{ +#if GTK_CHECK_VERSION(2,24,0) + g_bPartSelectorBroadcast = false; + gtk_combo_box_set_active(GTK_COMBO_BOX(pPartSelector), nPart); + g_bPartSelectorBroadcast = true; +#endif +} + /// User clicked on a cmmand button -> inform LOKDocView. static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/) { @@ -285,7 +296,7 @@ static void changePart( GtkWidget* pSelector, gpointer /* pItem */ ) { int nPart = gtk_combo_box_get_active( GTK_COMBO_BOX(pSelector) ); - if ( pDocView ) + if (g_bPartSelectorBroadcast && pDocView) { lok_docview_set_part( LOK_DOCVIEW(pDocView), nPart ); } @@ -436,6 +447,7 @@ int main( int argc, char* argv[] ) 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); + g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), 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 c04fa3e49302..f15027984f7f 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -194,6 +194,8 @@ struct LOKDocView_Impl void commandChanged(const std::string& rPayload); /// Search did not find any matches. void searchNotFound(const std::string& rPayload); + /// LOK decided to change parts, need to update UI. + void setPart(const std::string& rPayload); }; namespace { @@ -1019,7 +1021,7 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback) break; case LOK_CALLBACK_SET_PART: { - renderDocument(0); + setPart(pCallback->m_aPayload); } break; default: @@ -1066,6 +1068,7 @@ enum EDIT_CHANGED, COMMAND_CHANGED, SEARCH_NOT_FOUND, + PART_CHANGED, LAST_SIGNAL }; @@ -1081,6 +1084,12 @@ void LOKDocView_Impl::searchNotFound(const std::string& rString) g_signal_emit(m_pDocView, docview_signals[SEARCH_NOT_FOUND], 0, rString.c_str()); } +void LOKDocView_Impl::setPart(const std::string& rString) +{ + g_signal_emit(m_pDocView, docview_signals[PART_CHANGED], 0, std::stoi(rString)); + renderDocument(0); +} + static void lok_docview_class_init( gpointer ptr ) { LOKDocViewClass* pClass = static_cast<LOKDocViewClass *>(ptr); @@ -1115,6 +1124,16 @@ static void lok_docview_class_init( gpointer ptr ) g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); + pClass->part_changed = 0; + docview_signals[PART_CHANGED] = + g_signal_new("part-changed", + G_TYPE_FROM_CLASS(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(LOKDocViewClass, part_changed), + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, + G_TYPE_INT); } static void lok_docview_init( GTypeInstance* pInstance, gpointer ) |