lokdocview: Use an array to install properties

This way we can directly reference any property by pointers to
GParamSpec stored in a static array, rather than looking for
property using property name. The former is a faster approach.

This will come in handy for functions, such as, g_object_notify
which needs to access properties to notify the object of any
property change in a faster way.

Change-Id: Ic4087bff3bdb63a3e8853d158c7af688e5e67811
Reviewed-on: https://gerrit.libreoffice.org/20797
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
This commit is contained in:
Pranav Kant
2015-12-18 21:51:23 +05:30
committed by David Tardon
parent 41dde8319c
commit 81f31f5151

View File

@@ -205,10 +205,13 @@ enum
PROP_DOC_WIDTH, PROP_DOC_WIDTH,
PROP_DOC_HEIGHT, PROP_DOC_HEIGHT,
PROP_CAN_ZOOM_IN, PROP_CAN_ZOOM_IN,
PROP_CAN_ZOOM_OUT PROP_CAN_ZOOM_OUT,
PROP_LAST
}; };
static guint doc_view_signals[LAST_SIGNAL] = { 0 }; static guint doc_view_signals[LAST_SIGNAL] = { 0 };
static GParamSpec *properties[PROP_LAST] = { nullptr };
static void lok_doc_view_initable_iface_init (GInitableIface *iface); static void lok_doc_view_initable_iface_init (GInitableIface *iface);
static void callbackWorker (int nType, const char* pPayload, void* pData); static void callbackWorker (int nType, const char* pPayload, void* pData);
@@ -2047,15 +2050,14 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
* *
* The absolute path of the LibreOffice install. * The absolute path of the LibreOffice install.
*/ */
g_object_class_install_property (pGObjectClass, properties[PROP_LO_PATH] =
PROP_LO_PATH,
g_param_spec_string("lopath", g_param_spec_string("lopath",
"LO Path", "LO Path",
"LibreOffice Install Path", "LibreOffice Install Path",
nullptr, nullptr,
static_cast<GParamFlags>(G_PARAM_READWRITE | static_cast<GParamFlags>(G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS))); G_PARAM_STATIC_STRINGS));
/** /**
* LOKDocView:lopointer: * LOKDocView:lopointer:
@@ -2063,28 +2065,26 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
* A LibreOfficeKit* in case lok_init() is already called * A LibreOfficeKit* in case lok_init() is already called
* previously. * previously.
*/ */
g_object_class_install_property (pGObjectClass, properties[PROP_LO_POINTER] =
PROP_LO_POINTER,
g_param_spec_pointer("lopointer", g_param_spec_pointer("lopointer",
"LO Pointer", "LO Pointer",
"A LibreOfficeKit* from lok_init()", "A LibreOfficeKit* from lok_init()",
static_cast<GParamFlags>(G_PARAM_READWRITE | static_cast<GParamFlags>(G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS))); G_PARAM_STATIC_STRINGS));
/** /**
* LOKDocView:docpath: * LOKDocView:docpath:
* *
* The path of the document that is currently being viewed. * The path of the document that is currently being viewed.
*/ */
g_object_class_install_property (pGObjectClass, properties[PROP_DOC_PATH] =
PROP_DOC_PATH,
g_param_spec_string("docpath", g_param_spec_string("docpath",
"Document Path", "Document Path",
"The URI of the document to open", "The URI of the document to open",
nullptr, nullptr,
static_cast<GParamFlags>(G_PARAM_READWRITE | static_cast<GParamFlags>(G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS))); G_PARAM_STATIC_STRINGS));
/** /**
* LOKDocView:docpointer: * LOKDocView:docpointer:
@@ -2092,27 +2092,25 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
* A LibreOfficeKitDocument* in case documentLoad() is already called * A LibreOfficeKitDocument* in case documentLoad() is already called
* previously. * previously.
*/ */
g_object_class_install_property (pGObjectClass, properties[PROP_DOC_POINTER] =
PROP_DOC_POINTER,
g_param_spec_pointer("docpointer", g_param_spec_pointer("docpointer",
"Document Pointer", "Document Pointer",
"A LibreOfficeKitDocument* from documentLoad()", "A LibreOfficeKitDocument* from documentLoad()",
static_cast<GParamFlags>(G_PARAM_READWRITE | static_cast<GParamFlags>(G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS))); G_PARAM_STATIC_STRINGS));
/** /**
* LOKDocView:editable: * LOKDocView:editable:
* *
* Whether the document loaded inside of #LOKDocView is editable or not. * Whether the document loaded inside of #LOKDocView is editable or not.
*/ */
g_object_class_install_property (pGObjectClass, properties[PROP_EDITABLE] =
PROP_EDITABLE,
g_param_spec_boolean("editable", g_param_spec_boolean("editable",
"Editable", "Editable",
"Whether the content is in edit mode or not", "Whether the content is in edit mode or not",
FALSE, FALSE,
static_cast<GParamFlags>(G_PARAM_READWRITE | static_cast<GParamFlags>(G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS))); G_PARAM_STATIC_STRINGS));
/** /**
* LOKDocView:load-progress: * LOKDocView:load-progress:
@@ -2122,14 +2120,13 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
* very accurate progress indicator, and its value might reset it couple of * very accurate progress indicator, and its value might reset it couple of
* times to 0 and start again. You should not rely on its numbers. * times to 0 and start again. You should not rely on its numbers.
*/ */
g_object_class_install_property (pGObjectClass, properties[PROP_LOAD_PROGRESS] =
PROP_LOAD_PROGRESS,
g_param_spec_double("load-progress", g_param_spec_double("load-progress",
"Estimated Load Progress", "Estimated Load Progress",
"Shows the progress of the document load operation", "Shows the progress of the document load operation",
0.0, 1.0, 0.0, 0.0, 1.0, 0.0,
static_cast<GParamFlags>(G_PARAM_READABLE | static_cast<GParamFlags>(G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS))); G_PARAM_STATIC_STRINGS));
/** /**
* LOKDocView:zoom-level: * LOKDocView:zoom-level:
@@ -2137,14 +2134,13 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
* The current zoom level of the document loaded inside #LOKDocView. The * The current zoom level of the document loaded inside #LOKDocView. The
* default value is 1.0. * default value is 1.0.
*/ */
g_object_class_install_property (pGObjectClass, properties[PROP_ZOOM] =
PROP_ZOOM,
g_param_spec_float("zoom-level", g_param_spec_float("zoom-level",
"Zoom Level", "Zoom Level",
"The current zoom level of the content", "The current zoom level of the content",
0, 5.0, 1.0, 0, 5.0, 1.0,
static_cast<GParamFlags>(G_PARAM_READWRITE | static_cast<GParamFlags>(G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS))); G_PARAM_STATIC_STRINGS));
/** /**
* LOKDocView:is-loading: * LOKDocView:is-loading:
@@ -2152,70 +2148,67 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
* Whether the requested document is being loaded or not. %TRUE if it is * Whether the requested document is being loaded or not. %TRUE if it is
* being loaded, otherwise %FALSE. * being loaded, otherwise %FALSE.
*/ */
g_object_class_install_property (pGObjectClass, properties[PROP_IS_LOADING] =
PROP_IS_LOADING,
g_param_spec_boolean("is-loading", g_param_spec_boolean("is-loading",
"Is Loading", "Is Loading",
"Whether the view is loading a document", "Whether the view is loading a document",
FALSE, FALSE,
static_cast<GParamFlags>(G_PARAM_READABLE | static_cast<GParamFlags>(G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS))); G_PARAM_STATIC_STRINGS));
/** /**
* LOKDocView:doc-width: * LOKDocView:doc-width:
* *
* The width of the currently loaded document in #LOKDocView in twips. * The width of the currently loaded document in #LOKDocView in twips.
*/ */
g_object_class_install_property (pGObjectClass, properties[PROP_DOC_WIDTH] =
PROP_DOC_WIDTH,
g_param_spec_long("doc-width", g_param_spec_long("doc-width",
"Document Width", "Document Width",
"Width of the document in twips", "Width of the document in twips",
0, G_MAXLONG, 0, 0, G_MAXLONG, 0,
static_cast<GParamFlags>(G_PARAM_READWRITE | static_cast<GParamFlags>(G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS))); G_PARAM_STATIC_STRINGS));
/** /**
* LOKDocView:doc-height: * LOKDocView:doc-height:
* *
* The height of the currently loaded document in #LOKDocView in twips. * The height of the currently loaded document in #LOKDocView in twips.
*/ */
g_object_class_install_property (pGObjectClass, properties[PROP_DOC_HEIGHT] =
PROP_DOC_HEIGHT,
g_param_spec_long("doc-height", g_param_spec_long("doc-height",
"Document Height", "Document Height",
"Height of the document in twips", "Height of the document in twips",
0, G_MAXLONG, 0, 0, G_MAXLONG, 0,
static_cast<GParamFlags>(G_PARAM_READWRITE | static_cast<GParamFlags>(G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS))); G_PARAM_STATIC_STRINGS));
/** /**
* LOKDocView:can-zoom-in: * LOKDocView:can-zoom-in:
* *
* It tells whether the view can further be zoomed in or not. * It tells whether the view can further be zoomed in or not.
*/ */
g_object_class_install_property (pGObjectClass, properties[PROP_CAN_ZOOM_IN] =
PROP_CAN_ZOOM_IN,
g_param_spec_boolean("can-zoom-in", g_param_spec_boolean("can-zoom-in",
"Can Zoom In", "Can Zoom In",
"Whether the view can be zoomed in further", "Whether the view can be zoomed in further",
TRUE, TRUE,
static_cast<GParamFlags>(G_PARAM_READABLE static_cast<GParamFlags>(G_PARAM_READABLE
| G_PARAM_STATIC_STRINGS))); | G_PARAM_STATIC_STRINGS));
/** /**
* LOKDocView:can-zoom-out: * LOKDocView:can-zoom-out:
* *
* It tells whether the view can further be zoomed out or not. * It tells whether the view can further be zoomed out or not.
*/ */
g_object_class_install_property (pGObjectClass, properties[PROP_CAN_ZOOM_OUT] =
PROP_CAN_ZOOM_OUT,
g_param_spec_boolean("can-zoom-out", g_param_spec_boolean("can-zoom-out",
"Can Zoom Out", "Can Zoom Out",
"Whether the view can be zoomed out further", "Whether the view can be zoomed out further",
TRUE, TRUE,
static_cast<GParamFlags>(G_PARAM_READABLE static_cast<GParamFlags>(G_PARAM_READABLE
| G_PARAM_STATIC_STRINGS))); | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties(pGObjectClass, PROP_LAST, properties);
/** /**
* LOKDocView::load-changed: * LOKDocView::load-changed: