[Libreoffice-commits] core.git: Branch 'feature/gsoc-tiled-rendering' - include/LibreOfficeKit libreofficekit/qa libreofficekit/source
Pranav Kant
pranavk at gnome.org
Mon Jul 6 12:02:15 PDT 2015
include/LibreOfficeKit/LibreOfficeKitGtk.h | 2
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 44 +++++---------------
libreofficekit/source/gtk/lokdocview.cxx | 41 ++----------------
3 files changed, 17 insertions(+), 70 deletions(-)
New commits:
commit af3ff4f4b4db6a2f540fbc95040ac5ab145d3adb
Author: Pranav Kant <pranavk at gnome.org>
Date: Tue Jul 7 00:30:41 2015 +0530
lokdocview: [WIP] Superfluous signals
Callback always gets invoked after the load finishes. So, lets
use that.
Change-Id: Ifa221684c7e6f286fe3434119ae5f21e2e02ea37
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index d536e4a..ec28348 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -45,7 +45,7 @@ GtkWidget* lok_doc_view_new (const gchar*
GCancellable *cancellable,
GError **error);
-gboolean lok_doc_view_open_document (LOKDocView* pDocView,
+void lok_doc_view_open_document (LOKDocView* pDocView,
const gchar* pPath,
GCancellable* cancellable,
GAsyncReadyCallback callback,
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index fed62c4..af3ba41 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -382,15 +382,17 @@ static void changePartMode( GtkWidget* pSelector, gpointer /* pItem */ )
}
}
-
-static void loadStarted(LOKDocView* pDocView, gpointer pData)
+static void openDocumentCallback (GObject* source_object, GAsyncResult* res, gpointer /*userdata*/)
{
- g_info ("load started");
-}
+ LOKDocView* pDocView1 = LOK_DOC_VIEW (source_object);
+ GError* error = NULL;
+ GList *focusChain = NULL;
-static void loadFinished(LOKDocView* pDocView, gboolean status, gpointer pData)
-{
- g_info ("load finished");
+ if (!lok_doc_view_open_document_finish(pDocView1, res, &error))
+ {
+ g_warning ("Error occurred while opening the document : %s", error->message);
+ g_error_free (error);
+ }
populatePartSelector();
populatePartModeSelector( GTK_COMBO_BOX_TEXT(pPartModeComboBox) );
@@ -398,29 +400,10 @@ static void loadFinished(LOKDocView* pDocView, gboolean status, gpointer pData)
g_signal_connect(G_OBJECT(pPartModeComboBox), "changed", G_CALLBACK(changePartMode), 0);
g_signal_connect(G_OBJECT(pPartSelector), "changed", G_CALLBACK(changePart), 0);
- GList *focusChain = NULL;
- focusChain = g_list_append( focusChain, pDocView );
+ focusChain = g_list_append( focusChain, pDocView1 );
gtk_container_set_focus_chain ( GTK_CONTAINER (pVBox), focusChain );
}
-static void open_document_cb (GObject* source_object, GAsyncResult* res, gpointer userdata)
-{
- LOKDocView* pDocView = LOK_DOC_VIEW (source_object);
- GError* error = NULL;
-
- gboolean result = lok_doc_view_open_document_finish(pDocView, res, &error);
- if (result){
- g_info ("open_document results to true");
- }else
- g_info ("open document results to false");
-
- if (error != NULL)
- {
- g_warning ("Error occurred while opening the document : %s", error->message);
- g_error_free (error);
- }
-}
-
int main( int argc, char* argv[] )
{
if( argc < 3 ||
@@ -571,9 +554,6 @@ int main( int argc, char* argv[] )
g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), NULL);
g_signal_connect(pDocView, "hyperlink-clicked", G_CALLBACK(signalHyperlink), NULL);
- g_signal_connect(pDocView, "load-started", G_CALLBACK(loadStarted), NULL);
- g_signal_connect(pDocView, "load-finished", G_CALLBACK(loadFinished), NULL);
-
// Scrolled window for DocView
pScrolledWindow = gtk_scrolled_window_new(0, 0);
gtk_widget_set_hexpand (pScrolledWindow, TRUE);
@@ -586,9 +566,7 @@ int main( int argc, char* argv[] )
// Hide the findbar by default.
gtk_widget_hide(pFindbar);
- int bOpened = lok_doc_view_open_document( LOK_DOC_VIEW(pDocView), argv[2], NULL, open_document_cb, pDocView );
- if (!bOpened)
- g_error("main: lok_doc_view_open_document() failed");
+ lok_doc_view_open_document( LOK_DOC_VIEW(pDocView), argv[2], NULL, openDocumentCallback, pDocView );
gtk_main();
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index f9b332c..7e11d06 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -337,19 +337,23 @@ static gboolean
globalCallback (gpointer pData)
{
CallbackData* pCallback = static_cast<CallbackData*>(pData);
+ LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pCallback->m_pDocView));
switch (pCallback->m_nType)
{
case LOK_CALLBACK_STATUS_INDICATOR_START:
{
+ priv->m_nLoadProgress = 0;
}
break;
case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE:
{
+ priv->m_nLoadProgress = std::stoi(pCallback->m_aPayload);
}
break;
case LOK_CALLBACK_STATUS_INDICATOR_FINISH:
{
+ priv->m_nLoadProgress = 100;
}
break;
default:
@@ -1298,34 +1302,6 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
| G_PARAM_STATIC_STRINGS)));
/**
- * LOKDocView::load-started:
- * @pDocView: the #LOKDocView on which the signal is emitted
- */
- doc_view_signals[LOAD_STARTED] =
- g_signal_new("load-started",
- G_TYPE_FROM_CLASS (pGObjectClass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /**
- * LOKDocView::load-finished:
- * @pDocView: the #LOKDocView on which the signal is emitted
- * @bStatus: whether the load finished successfully or it failed
- */
- doc_view_signals[LOAD_FINISHED] =
- g_signal_new("load-finished",
- G_TYPE_FROM_CLASS(pGObjectClass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1,
- G_TYPE_BOOLEAN);
-
- /**
* LOKDocView::edit-changed:
* @pDocView: the #LOKDocView on which the signal is emitted
* @bEdit: the new edit value of the view
@@ -1448,8 +1424,6 @@ lok_doc_view_open_document_func (GTask* task, gpointer source_object, gpointer t
priv->m_pDocument = 0;
}
- g_signal_emit(pDocView, doc_view_signals[LOAD_STARTED], 0);
-
priv->m_pOffice->pClass->registerCallback(priv->m_pOffice, globalCallbackWorker, pDocView);
priv->m_pDocument = priv->m_pOffice->pClass->documentLoad( priv->m_pOffice, priv->m_aDocPath );
if ( !priv->m_pDocument )
@@ -1457,7 +1431,6 @@ lok_doc_view_open_document_func (GTask* task, gpointer source_object, gpointer t
// FIXME: should have a GError parameter and populate it.
char *pError = priv->m_pOffice->pClass->getError( priv->m_pOffice );
fprintf( stderr, "Error opening document '%s'\n", pError );
- g_signal_emit(pDocView, doc_view_signals[LOAD_FINISHED], 0, false/* implies failure*/);
g_task_return_new_error(task, 0, 0, pError);
}
else
@@ -1483,8 +1456,6 @@ lok_doc_view_open_document_func (GTask* task, gpointer source_object, gpointer t
nDocumentHeightPixels);
gtk_widget_set_can_focus(GTK_WIDGET(pDocView), TRUE);
gtk_widget_grab_focus(GTK_WIDGET(pDocView));
- g_signal_emit(pDocView, doc_view_signals[LOAD_FINISHED], 0, true/* implies
- success */);
g_task_return_boolean (task, true);
}
}
@@ -1496,7 +1467,7 @@ lok_doc_view_open_document_func (GTask* task, gpointer source_object, gpointer t
*
* Returns: %TRUE if the document is loaded succesfully, %FALSE otherwise
*/
-SAL_DLLPUBLIC_EXPORT gboolean
+SAL_DLLPUBLIC_EXPORT void
lok_doc_view_open_document (LOKDocView* pDocView,
const gchar* pPath,
GCancellable* cancellable,
@@ -1513,8 +1484,6 @@ lok_doc_view_open_document (LOKDocView* pDocView,
g_task_run_in_thread(task, lok_doc_view_open_document_func);
g_object_unref(task);
-
- return true;
}
/**
More information about the Libreoffice-commits
mailing list