lokdocview: allow not calling documentLoad()

Change-Id: I2ff57c4be11cd3908bc951ebf572a2c02e2c4585
This commit is contained in:
Miklos Vajna 2015-09-15 14:23:53 +02:00
parent d51e3f7877
commit 4fd59356cb
2 changed files with 50 additions and 0 deletions

View File

@ -44,6 +44,8 @@ GtkWidget* lok_doc_view_new (const gchar*
GCancellable *cancellable,
GError **error);
GtkWidget* lok_doc_view_new_from_widget (LOKDocView* pDocView);
void lok_doc_view_open_document (LOKDocView* pDocView,
const gchar* pPath,
GCancellable* cancellable,

View File

@ -127,7 +127,9 @@ enum
PROP_0,
PROP_LO_PATH,
PROP_LO_POINTER,
PROP_DOC_PATH,
PROP_DOC_POINTER,
PROP_EDITABLE,
PROP_LOAD_PROGRESS,
PROP_ZOOM,
@ -1388,9 +1390,15 @@ static void lok_doc_view_set_property (GObject* object, guint propId, const GVal
case PROP_LO_PATH:
priv->m_aLOPath = g_value_dup_string (value);
break;
case PROP_LO_POINTER:
priv->m_pOffice = static_cast<LibreOfficeKit*>(g_value_get_pointer(value));
break;
case PROP_DOC_PATH:
priv->m_aDocPath = g_value_dup_string (value);
break;
case PROP_DOC_POINTER:
priv->m_pDocument = static_cast<LibreOfficeKitDocument*>(g_value_get_pointer(value));
break;
case PROP_EDITABLE:
lok_doc_view_set_edit (pDocView, g_value_get_boolean (value));
break;
@ -1418,9 +1426,15 @@ static void lok_doc_view_get_property (GObject* object, guint propId, GValue *va
case PROP_LO_PATH:
g_value_set_string (value, priv->m_aLOPath);
break;
case PROP_LO_POINTER:
g_value_set_pointer(value, priv->m_pOffice);
break;
case PROP_DOC_PATH:
g_value_set_string (value, priv->m_aDocPath);
break;
case PROP_DOC_POINTER:
g_value_set_pointer(value, priv->m_pDocument);
break;
case PROP_EDITABLE:
g_value_set_boolean (value, priv->m_bEdit);
break;
@ -1530,6 +1544,20 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
static_cast<GParamFlags>(G_PARAM_READWRITE
| G_PARAM_CONSTRUCT_ONLY)));
/**
* LOKDocView:lopointer:
*
* A LibreOfficeKit* in case lok_init() is already called
* previously.
*/
g_object_class_install_property (pGObjectClass,
PROP_LO_POINTER,
g_param_spec_pointer("lopointer",
"LO Pointer",
"A LibreOfficeKit* from lok_init()",
static_cast<GParamFlags>(G_PARAM_READWRITE
| G_PARAM_CONSTRUCT_ONLY)));
/**
* LOKDocView:docpath:
*
@ -1543,6 +1571,19 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
0,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
/**
* LOKDocView:docpointer:
*
* A LibreOfficeKitDocument* in case documentLoad() is already called
* previously.
*/
g_object_class_install_property (pGObjectClass,
PROP_DOC_POINTER,
g_param_spec_pointer("docpointer",
"Document Pointer",
"A LibreOfficeKitDocument* from documentLoad()",
static_cast<GParamFlags>(G_PARAM_READWRITE)));
/**
* LOKDocView:editable:
*
@ -1795,6 +1836,13 @@ lok_doc_view_new (const gchar* pPath, GCancellable *cancellable, GError **error)
return GTK_WIDGET (g_initable_new (LOK_TYPE_DOC_VIEW, cancellable, error, "lopath", pPath, NULL));
}
SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new_from_widget(LOKDocView* pLOKDocView)
{
LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private(pLOKDocView));
return GTK_WIDGET(g_initable_new(LOK_TYPE_DOC_VIEW, /*cancellable=*/0, /*error=*/0,
"lopath", priv->m_aLOPath, "lopointer", priv->m_pOffice, "docpointer", priv->m_pDocument, NULL));
}
/**
* lok_doc_view_open_document_finish:
* @pDocView: The #LOKDocView instance