[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - 2 commits - libreofficekit/source

Pranav Kant pranavk at libreoffice.org
Mon Jan 11 02:13:37 PST 2016


 libreofficekit/source/gtk/lokdocview.cxx |  189 +++++++++++++++----------------
 1 file changed, 92 insertions(+), 97 deletions(-)

New commits:
commit 1fb882cb1e2eedbef688cf2b3a2ca9322486c9cb
Author: Pranav Kant <pranavk at libreoffice.org>
Date:   Fri Dec 18 21:58:26 2015 +0530

    tdf#96514: Emits a 'notify' signal when zoom changes
    
    Change-Id: I5f55e4cce26096afcae3ad3711efa37757aada39
    Reviewed-on: https://gerrit.libreoffice.org/20798
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>
    (cherry picked from commit 398ef76d5dc3ec1ed22fa1d9fd9151b61cce54e2)
    Reviewed-on: https://gerrit.libreoffice.org/21273
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Pranav Kant <pranavk at gnome.org>

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index e29db43..d091bb9 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2485,6 +2485,8 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
                                 nDocumentWidthPixels,
                                 nDocumentHeightPixels);
 
+    g_object_notify_by_pspec(G_OBJECT(pDocView), properties[PROP_ZOOM]);
+
     // Update the client's view size
     GTask* task = g_task_new(pDocView, nullptr, nullptr, nullptr);
     LOEvent* pLOEvent = new LOEvent(LOK_SET_CLIENT_ZOOM);
commit 09c73ad5b1462161b855bf3d43a3d86a3ee28659
Author: Pranav Kant <pranavk at libreoffice.org>
Date:   Fri Dec 18 21:51:23 2015 +0530

    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 at libreoffice.org>
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>
    (cherry picked from commit 81f31f5151b54899ac5461c9c7c4021cdf31a9a6)
    Reviewed-on: https://gerrit.libreoffice.org/21272
    Reviewed-by: Pranav Kant <pranavk at gnome.org>

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 426773c..e29db43 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -206,10 +206,13 @@ enum
     PROP_DOC_WIDTH,
     PROP_DOC_HEIGHT,
     PROP_CAN_ZOOM_IN,
-    PROP_CAN_ZOOM_OUT
+    PROP_CAN_ZOOM_OUT,
+
+    PROP_LAST
 };
 
 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 callbackWorker (int nType, const char* pPayload, void* pData);
@@ -2048,15 +2051,14 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
      *
      * The absolute path of the LibreOffice install.
      */
-    g_object_class_install_property (pGObjectClass,
-          PROP_LO_PATH,
-          g_param_spec_string("lopath",
-                              "LO Path",
-                              "LibreOffice Install Path",
-                              nullptr,
-                              static_cast<GParamFlags>(G_PARAM_READWRITE |
-                                                       G_PARAM_CONSTRUCT_ONLY |
-                                                       G_PARAM_STATIC_STRINGS)));
+    properties[PROP_LO_PATH] =
+        g_param_spec_string("lopath",
+                            "LO Path",
+                            "LibreOffice Install Path",
+                            nullptr,
+                            static_cast<GParamFlags>(G_PARAM_READWRITE |
+                                                     G_PARAM_CONSTRUCT_ONLY |
+                                                     G_PARAM_STATIC_STRINGS));
 
     /**
      * LOKDocView:lopointer:
@@ -2064,28 +2066,26 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
      * 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 |
-                                                        G_PARAM_STATIC_STRINGS)));
+    properties[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 |
+                                                      G_PARAM_STATIC_STRINGS));
 
     /**
      * LOKDocView:docpath:
      *
      * The path of the document that is currently being viewed.
      */
-    g_object_class_install_property (pGObjectClass,
-          PROP_DOC_PATH,
-          g_param_spec_string("docpath",
-                              "Document Path",
-                              "The URI of the document to open",
-                              nullptr,
-                              static_cast<GParamFlags>(G_PARAM_READWRITE |
-                                                       G_PARAM_STATIC_STRINGS)));
+    properties[PROP_DOC_PATH] =
+        g_param_spec_string("docpath",
+                            "Document Path",
+                            "The URI of the document to open",
+                            nullptr,
+                            static_cast<GParamFlags>(G_PARAM_READWRITE |
+                                                     G_PARAM_STATIC_STRINGS));
 
     /**
      * LOKDocView:docpointer:
@@ -2093,27 +2093,25 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
      * 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 |
-                                                        G_PARAM_STATIC_STRINGS)));
+    properties[PROP_DOC_POINTER] =
+        g_param_spec_pointer("docpointer",
+                             "Document Pointer",
+                             "A LibreOfficeKitDocument* from documentLoad()",
+                             static_cast<GParamFlags>(G_PARAM_READWRITE |
+                                                      G_PARAM_STATIC_STRINGS));
 
     /**
      * LOKDocView:editable:
      *
      * Whether the document loaded inside of #LOKDocView is editable or not.
      */
-    g_object_class_install_property (pGObjectClass,
-          PROP_EDITABLE,
-          g_param_spec_boolean("editable",
-                               "Editable",
-                               "Whether the content is in edit mode or not",
-                               FALSE,
-                               static_cast<GParamFlags>(G_PARAM_READWRITE |
-                                                        G_PARAM_STATIC_STRINGS)));
+    properties[PROP_EDITABLE] =
+        g_param_spec_boolean("editable",
+                             "Editable",
+                             "Whether the content is in edit mode or not",
+                             FALSE,
+                             static_cast<GParamFlags>(G_PARAM_READWRITE |
+                                                      G_PARAM_STATIC_STRINGS));
 
     /**
      * LOKDocView:load-progress:
@@ -2123,14 +2121,13 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
      * 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.
      */
-    g_object_class_install_property (pGObjectClass,
-          PROP_LOAD_PROGRESS,
-          g_param_spec_double("load-progress",
-                              "Estimated Load Progress",
-                              "Shows the progress of the document load operation",
-                              0.0, 1.0, 0.0,
-                              static_cast<GParamFlags>(G_PARAM_READABLE |
-                                                       G_PARAM_STATIC_STRINGS)));
+    properties[PROP_LOAD_PROGRESS] =
+        g_param_spec_double("load-progress",
+                            "Estimated Load Progress",
+                            "Shows the progress of the document load operation",
+                            0.0, 1.0, 0.0,
+                            static_cast<GParamFlags>(G_PARAM_READABLE |
+                                                     G_PARAM_STATIC_STRINGS));
 
     /**
      * LOKDocView:zoom-level:
@@ -2138,14 +2135,13 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
      * The current zoom level of the document loaded inside #LOKDocView. The
      * default value is 1.0.
      */
-    g_object_class_install_property (pGObjectClass,
-          PROP_ZOOM,
-          g_param_spec_float("zoom-level",
-                             "Zoom Level",
-                             "The current zoom level of the content",
-                             0, 5.0, 1.0,
-                             static_cast<GParamFlags>(G_PARAM_READWRITE |
-                                                      G_PARAM_STATIC_STRINGS)));
+    properties[PROP_ZOOM] =
+        g_param_spec_float("zoom-level",
+                           "Zoom Level",
+                           "The current zoom level of the content",
+                           0, 5.0, 1.0,
+                           static_cast<GParamFlags>(G_PARAM_READWRITE |
+                                                    G_PARAM_STATIC_STRINGS));
 
     /**
      * LOKDocView:is-loading:
@@ -2153,70 +2149,67 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
      * Whether the requested document is being loaded or not. %TRUE if it is
      * being loaded, otherwise %FALSE.
      */
-    g_object_class_install_property (pGObjectClass,
-          PROP_IS_LOADING,
-          g_param_spec_boolean("is-loading",
-                               "Is Loading",
-                               "Whether the view is loading a document",
-                               FALSE,
-                               static_cast<GParamFlags>(G_PARAM_READABLE |
-                                                        G_PARAM_STATIC_STRINGS)));
+    properties[PROP_IS_LOADING] =
+        g_param_spec_boolean("is-loading",
+                             "Is Loading",
+                             "Whether the view is loading a document",
+                             FALSE,
+                             static_cast<GParamFlags>(G_PARAM_READABLE |
+                                                      G_PARAM_STATIC_STRINGS));
 
     /**
      * LOKDocView:doc-width:
      *
      * The width of the currently loaded document in #LOKDocView in twips.
      */
-    g_object_class_install_property (pGObjectClass,
-          PROP_DOC_WIDTH,
-          g_param_spec_long("doc-width",
-                            "Document Width",
-                            "Width of the document in twips",
-                            0, G_MAXLONG, 0,
-                            static_cast<GParamFlags>(G_PARAM_READWRITE |
-                                                     G_PARAM_STATIC_STRINGS)));
+    properties[PROP_DOC_WIDTH] =
+        g_param_spec_long("doc-width",
+                          "Document Width",
+                          "Width of the document in twips",
+                          0, G_MAXLONG, 0,
+                          static_cast<GParamFlags>(G_PARAM_READWRITE |
+                                                   G_PARAM_STATIC_STRINGS));
 
     /**
      * LOKDocView:doc-height:
      *
      * The height of the currently loaded document in #LOKDocView in twips.
      */
-    g_object_class_install_property (pGObjectClass,
-          PROP_DOC_HEIGHT,
-          g_param_spec_long("doc-height",
-                            "Document Height",
-                            "Height of the document in twips",
-                            0, G_MAXLONG, 0,
-                            static_cast<GParamFlags>(G_PARAM_READWRITE |
-                                                     G_PARAM_STATIC_STRINGS)));
+    properties[PROP_DOC_HEIGHT] =
+        g_param_spec_long("doc-height",
+                          "Document Height",
+                          "Height of the document in twips",
+                          0, G_MAXLONG, 0,
+                          static_cast<GParamFlags>(G_PARAM_READWRITE |
+                                                   G_PARAM_STATIC_STRINGS));
 
     /**
      * LOKDocView:can-zoom-in:
      *
      * It tells whether the view can further be zoomed in or not.
      */
-    g_object_class_install_property (pGObjectClass,
-          PROP_CAN_ZOOM_IN,
-          g_param_spec_boolean("can-zoom-in",
-                               "Can Zoom In",
-                               "Whether the view can be zoomed in further",
-                               TRUE,
-                               static_cast<GParamFlags>(G_PARAM_READABLE
-                                                       | G_PARAM_STATIC_STRINGS)));
+    properties[PROP_CAN_ZOOM_IN] =
+        g_param_spec_boolean("can-zoom-in",
+                             "Can Zoom In",
+                             "Whether the view can be zoomed in further",
+                             TRUE,
+                             static_cast<GParamFlags>(G_PARAM_READABLE
+                                                      | G_PARAM_STATIC_STRINGS));
 
     /**
      * LOKDocView:can-zoom-out:
      *
      * It tells whether the view can further be zoomed out or not.
      */
-    g_object_class_install_property (pGObjectClass,
-          PROP_CAN_ZOOM_OUT,
-          g_param_spec_boolean("can-zoom-out",
-                               "Can Zoom Out",
-                               "Whether the view can be zoomed out further",
-                               TRUE,
-                               static_cast<GParamFlags>(G_PARAM_READABLE
-                                                       | G_PARAM_STATIC_STRINGS)));
+    properties[PROP_CAN_ZOOM_OUT] =
+        g_param_spec_boolean("can-zoom-out",
+                             "Can Zoom Out",
+                             "Whether the view can be zoomed out further",
+                             TRUE,
+                             static_cast<GParamFlags>(G_PARAM_READABLE
+                                                      | G_PARAM_STATIC_STRINGS));
+
+    g_object_class_install_properties(pGObjectClass, PROP_LAST, properties);
 
     /**
      * LOKDocView::load-changed:


More information about the Libreoffice-commits mailing list