lokdocview: Separate gobject property for turning off comments
Pass --enable-tiled-annotations to gtktiledviewer on command line to turn comments on again, by default they are turned off now. Change-Id: I40e93ab683ec9538e088ae9aa83cda2eaaf9939e Reviewed-on: https://gerrit.libreoffice.org/33622 Reviewed-by: pranavk <pranavk@collabora.co.uk> Tested-by: pranavk <pranavk@collabora.co.uk>
This commit is contained in:
parent
99a2a1f975
commit
3616f875b0
@ -288,7 +288,11 @@ gboolean CommentsSidebar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfigu
|
||||
TiledWindow& rWindow = lcl_getTiledWindow(pDocView);
|
||||
LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(pDocView));
|
||||
|
||||
if (pDocument && pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_TEXT)
|
||||
// whether tield rendering is turned on
|
||||
gboolean bTiledAnnotations;
|
||||
g_object_get(G_OBJECT(pDocView), "tiled-annotations", &bTiledAnnotations, nullptr);
|
||||
|
||||
if (!bTiledAnnotations && pDocument && pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_TEXT)
|
||||
{
|
||||
if (!rWindow.m_pCommentsSidebar)
|
||||
{
|
||||
@ -933,19 +937,20 @@ static void toggleFindbar(GtkWidget* pButton, gpointer /*pItem*/)
|
||||
}
|
||||
|
||||
static void
|
||||
setLOKFeatures (GtkWidget* pDocView)
|
||||
setLOKFeatures (GtkWidget* pDocView, gboolean bTiledAnnotations)
|
||||
{
|
||||
g_object_set(G_OBJECT(pDocView),
|
||||
"doc-password", TRUE,
|
||||
"doc-password-to-modify", TRUE,
|
||||
"tiled-annotations", bTiledAnnotations,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
/// Common initialization, regardless if it's just a new view or a full init.
|
||||
static TiledWindow& setupWidgetAndCreateWindow(GtkWidget* pDocView)
|
||||
static TiledWindow& setupWidgetAndCreateWindow(GtkWidget* pDocView, gboolean bTiledAnnotations)
|
||||
{
|
||||
setupDocView(pDocView);
|
||||
setLOKFeatures(pDocView);
|
||||
setLOKFeatures(pDocView, bTiledAnnotations);
|
||||
TiledWindow aWindow;
|
||||
aWindow.m_pDocView = pDocView;
|
||||
GtkWidget* pWindow = createWindow(aWindow);
|
||||
@ -974,8 +979,9 @@ static void createView(GtkWidget* pButton, gpointer /*pItem*/)
|
||||
std::string aArguments = aStream.str();
|
||||
|
||||
GtkWidget* pDocView = lok_doc_view_new_from_widget(LOK_DOC_VIEW(rWindow.m_pDocView), aArguments.c_str());
|
||||
|
||||
TiledWindow& rNewWindow = setupWidgetAndCreateWindow(pDocView);
|
||||
gboolean bTiledAnnotations;
|
||||
g_object_get(G_OBJECT(rWindow.m_pDocView), "tiled-annotations", &bTiledAnnotations, nullptr);
|
||||
TiledWindow& rNewWindow = setupWidgetAndCreateWindow(pDocView, bTiledAnnotations);
|
||||
// Hide the unused progress bar.
|
||||
gtk_widget_show_all(rNewWindow.m_pStatusBar);
|
||||
gtk_widget_hide(rNewWindow.m_pProgressBar);
|
||||
@ -988,17 +994,20 @@ static void createView(GtkWidget* pButton, gpointer /*pItem*/)
|
||||
static void createModelAndView(const char* pLOPath, const char* pDocPath, const std::vector<std::string>& rArguments)
|
||||
{
|
||||
std::string aUserProfile;
|
||||
gboolean bTiledAnnotations = FALSE;
|
||||
for (size_t i = 0; i < rArguments.size(); ++i)
|
||||
{
|
||||
const std::string& rArgument = rArguments[i];
|
||||
if (rArgument == "--user-profile" && i + 1 < rArguments.size())
|
||||
aUserProfile = std::string("vnd.sun.star.pathname:")
|
||||
+ rArguments[i + 1].c_str();
|
||||
else if (rArgument == "--enable-tiled-annotations")
|
||||
bTiledAnnotations = TRUE;
|
||||
}
|
||||
const gchar* pUserProfile = aUserProfile.empty() ? nullptr : aUserProfile.c_str();
|
||||
GtkWidget* pDocView = lok_doc_view_new_from_user_profile(pLOPath, pUserProfile, nullptr, nullptr);
|
||||
|
||||
TiledWindow& rWindow = setupWidgetAndCreateWindow(pDocView);
|
||||
TiledWindow& rWindow = setupWidgetAndCreateWindow(pDocView, bTiledAnnotations);
|
||||
|
||||
boost::property_tree::ptree aTree;
|
||||
for (size_t i = 0; i < rArguments.size(); ++i)
|
||||
|
@ -299,6 +299,7 @@ enum
|
||||
PROP_CAN_ZOOM_OUT,
|
||||
PROP_DOC_PASSWORD,
|
||||
PROP_DOC_PASSWORD_TO_MODIFY,
|
||||
PROP_TILED_ANNOTATIONS,
|
||||
|
||||
PROP_LAST
|
||||
};
|
||||
@ -2465,6 +2466,7 @@ static void lok_doc_view_set_property (GObject* object, guint propId, const GVal
|
||||
LOKDocViewPrivate& priv = getPrivate(pDocView);
|
||||
gboolean bDocPasswordEnabled = priv->m_nLOKFeatures & LOK_FEATURE_DOCUMENT_PASSWORD;
|
||||
gboolean bDocPasswordToModifyEnabled = priv->m_nLOKFeatures & LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY;
|
||||
gboolean bTiledAnnotationsEnabled = !(priv->m_nLOKFeatures & LOK_FEATURE_NO_TILED_ANNOTATIONS);
|
||||
|
||||
switch (propId)
|
||||
{
|
||||
@ -2510,6 +2512,13 @@ static void lok_doc_view_set_property (GObject* object, guint propId, const GVal
|
||||
priv->m_pOffice->pClass->setOptionalFeatures(priv->m_pOffice, priv->m_nLOKFeatures);
|
||||
}
|
||||
break;
|
||||
case PROP_TILED_ANNOTATIONS:
|
||||
if ( g_value_get_boolean (value) != bTiledAnnotationsEnabled)
|
||||
{
|
||||
priv->m_nLOKFeatures = priv->m_nLOKFeatures ^ LOK_FEATURE_NO_TILED_ANNOTATIONS;
|
||||
priv->m_pOffice->pClass->setOptionalFeatures(priv->m_pOffice, priv->m_nLOKFeatures);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propId, pspec);
|
||||
}
|
||||
@ -2567,6 +2576,9 @@ static void lok_doc_view_get_property (GObject* object, guint propId, GValue *va
|
||||
case PROP_DOC_PASSWORD_TO_MODIFY:
|
||||
g_value_set_boolean (value, priv->m_nLOKFeatures & LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY);
|
||||
break;
|
||||
case PROP_TILED_ANNOTATIONS:
|
||||
g_value_set_boolean (value, !(priv->m_nLOKFeatures & LOK_FEATURE_NO_TILED_ANNOTATIONS));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propId, pspec);
|
||||
}
|
||||
@ -2632,7 +2644,6 @@ static gboolean lok_doc_view_initable_init (GInitable *initable, GCancellable* /
|
||||
return FALSE;
|
||||
}
|
||||
priv->m_nLOKFeatures |= LOK_FEATURE_PART_IN_INVALIDATION_CALLBACK;
|
||||
priv->m_nLOKFeatures |= LOK_FEATURE_NO_TILED_ANNOTATIONS;
|
||||
priv->m_pOffice->pClass->setOptionalFeatures(priv->m_pOffice, priv->m_nLOKFeatures);
|
||||
|
||||
return TRUE;
|
||||
@ -2863,6 +2874,20 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
|
||||
static_cast<GParamFlags>(G_PARAM_READWRITE
|
||||
| G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* LOKDocView:tiled-annotations-rendering:
|
||||
*
|
||||
* Set it to false if client does not want LO to render comments in tiles and
|
||||
* instead interested in using comments API to access comments
|
||||
*/
|
||||
properties[PROP_TILED_ANNOTATIONS] =
|
||||
g_param_spec_boolean("tiled-annotations",
|
||||
"Render comments in tiles",
|
||||
"Whether the client wants in tile comment rendering",
|
||||
TRUE,
|
||||
static_cast<GParamFlags>(G_PARAM_READWRITE
|
||||
| G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_properties(pGObjectClass, PROP_LAST, properties);
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user