[Libreoffice-commits] core.git: 2 commits - libreofficekit/qa

Pranav Kant pranavk at collabora.co.uk
Thu Feb 16 04:53:53 UTC 2017


 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |  103 +++++++++-----------
 1 file changed, 49 insertions(+), 54 deletions(-)

New commits:
commit a6c4552e792f6ab20fae83d354b369defd3bb345
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 15 17:00:05 2017 +0530

    gtktiledviewer: This is a better place to change doc-specific controls
    
    Change-Id: Id8fbebe2f6e339120741ed3744b18f50941c995e

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 7a626b8..28a1f6b 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -587,11 +587,6 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
         gtk_widget_queue_draw(rWindow.m_pColumnBar->m_pDrawingArea);
         gtk_widget_show(rWindow.m_pFormulabarEntry);
 
-        // Change cell alignment uno commands for spreadsheet
-        lcl_registerToolItem(rWindow, rWindow.m_pLeftpara, ".uno:AlignLeft");
-        lcl_registerToolItem(rWindow, rWindow.m_pCenterpara, ".uno:AlignHorizontalCenter");
-        lcl_registerToolItem(rWindow, rWindow.m_pRightpara, ".uno:AlignRight");
-        gtk_widget_hide(GTK_WIDGET(rWindow.m_pJustifypara));
     }
 
     return TRUE;
@@ -1122,6 +1117,14 @@ static void initWindow(TiledWindow& rWindow)
         // used.
         gtk_widget_set_halign(GTK_WIDGET(rWindow.m_pDocView), GTK_ALIGN_START);
         gtk_widget_set_valign(GTK_WIDGET(rWindow.m_pDocView), GTK_ALIGN_START);
+
+        // Change cell alignment uno commands for spreadsheet
+        lcl_registerToolItem(rWindow, rWindow.m_pLeftpara, ".uno:AlignLeft");
+        lcl_registerToolItem(rWindow, rWindow.m_pCenterpara, ".uno:AlignHorizontalCenter");
+        lcl_registerToolItem(rWindow, rWindow.m_pRightpara, ".uno:AlignRight");
+        gtk_widget_hide(GTK_WIDGET(rWindow.m_pJustifypara));
+
+        lcl_registerToolItem(rWindow, rWindow.m_pDeleteComment, ".uno:DeleteNote");
     }
 
     // Fill our comments sidebar
commit 2d6ec9761df5fcd36dd0ce7964d1ae6876ec9943
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 15 16:42:49 2017 +0530

    gtktiledviewer: Kill CommentsSidebar's docConfigure
    
    Move this code to initWindow too
    
    Change-Id: I057d9b8f60b9da2c20b28901ab958f9fc2095df3

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 2f8dcdb..7a626b8 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -57,8 +57,6 @@ public:
     static GtkWidget* createCommentBox(const boost::property_tree::ptree& aComment);
     /// Click even handler for m_pViewAnnotationsButton
     static void unoViewAnnotations(GtkWidget* pWidget, gpointer userdata);
-    /// Configure event handler for window
-    static gboolean docConfigureEvent(GtkWidget* pWidget, GdkEventConfigure* pEvent, gpointer pData);
 };
 
 
@@ -433,41 +431,6 @@ void CommentsSidebar::unoViewAnnotations(GtkWidget* pWidget, gpointer /*userdata
     }
 }
 
-gboolean CommentsSidebar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfigure* /*pEvent*/, gpointer /*userdata*/)
-{
-    TiledWindow& rWindow = lcl_getTiledWindow(pDocView);
-    LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(pDocView));
-
-    // whether tiled 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)
-        {
-            rWindow.m_pCommentsSidebar.reset(new CommentsSidebar());
-            rWindow.m_pCommentsSidebar->m_pMainVBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
-            gtk_container_add(GTK_CONTAINER(rWindow.m_pMainHBox), rWindow.m_pCommentsSidebar->m_pMainVBox);
-
-            rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton = gtk_button_new_with_label(".uno:ViewAnnotations");
-#if GTK_CHECK_VERSION(3,12,0)
-            // Hack to make sidebar grid wide enough to not need any horizontal scrollbar
-            gtk_widget_set_margin_start(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton, 20);
-            gtk_widget_set_margin_end(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton, 20);
-#endif
-            gtk_container_add(GTK_CONTAINER(rWindow.m_pCommentsSidebar->m_pMainVBox), rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton);
-            g_signal_connect(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton, "clicked", G_CALLBACK(CommentsSidebar::unoViewAnnotations), nullptr);
-
-            gtk_widget_show_all(rWindow.m_pCommentsSidebar->m_pMainVBox);
-
-            gtk_button_clicked(GTK_BUTTON(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton));
-        }
-    }
-
-    return TRUE;
-}
-
 TiledRowColumnBar::TiledRowColumnBar(TiledBarType eType)
     : m_pDrawingArea(gtk_drawing_area_new()),
     m_nSizePixel(0),
@@ -631,7 +594,7 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
         gtk_widget_hide(GTK_WIDGET(rWindow.m_pJustifypara));
     }
 
-    return FALSE;
+    return TRUE;
 }
 
 TiledCornerButton::TiledCornerButton()
@@ -1150,6 +1113,46 @@ static void initWindow(TiledWindow& rWindow)
     gtk_widget_hide(rWindow.m_pProgressBar);
 
     gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(rWindow.m_pEnableEditing), TRUE);
+
+    LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(rWindow.m_pDocView));
+    if (pDocument && pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_SPREADSHEET)
+    {
+        // Align to top left corner, so the tiles are in sync with the
+        // row/column bar, even when zooming out enough that not all space is
+        // used.
+        gtk_widget_set_halign(GTK_WIDGET(rWindow.m_pDocView), GTK_ALIGN_START);
+        gtk_widget_set_valign(GTK_WIDGET(rWindow.m_pDocView), GTK_ALIGN_START);
+    }
+
+    // Fill our comments sidebar
+    gboolean bTiledAnnotations;
+    g_object_get(G_OBJECT(rWindow.m_pDocView), "tiled-annotations", &bTiledAnnotations, nullptr);
+
+    // comments api implemented only for writer, calc as of now
+    if (!bTiledAnnotations && pDocument &&
+        (pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_TEXT ||
+         pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_SPREADSHEET))
+    {
+        if (!rWindow.m_pCommentsSidebar)
+        {
+            rWindow.m_pCommentsSidebar.reset(new CommentsSidebar());
+            rWindow.m_pCommentsSidebar->m_pMainVBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+            gtk_container_add(GTK_CONTAINER(rWindow.m_pMainHBox), rWindow.m_pCommentsSidebar->m_pMainVBox);
+
+            rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton = gtk_button_new_with_label(".uno:ViewAnnotations");
+#if GTK_CHECK_VERSION(3,12,0)
+            // Hack to make sidebar grid wide enough to not need any horizontal scrollbar
+            gtk_widget_set_margin_start(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton, 20);
+            gtk_widget_set_margin_end(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton, 20);
+#endif
+            gtk_container_add(GTK_CONTAINER(rWindow.m_pCommentsSidebar->m_pMainVBox), rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton);
+            g_signal_connect(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton, "clicked", G_CALLBACK(CommentsSidebar::unoViewAnnotations), nullptr);
+
+            gtk_widget_show_all(rWindow.m_pCommentsSidebar->m_pMainVBox);
+
+            gtk_button_clicked(GTK_BUTTON(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton));
+        }
+    }
 }
 
 /// Creates a new view, i.e. no LOK init or document load.
@@ -1791,16 +1794,6 @@ static void openDocumentCallback (GObject* source_object, GAsyncResult* res, gpo
         return;
     }
 
-    LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(pDocView);
-    if (pDocument && pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_SPREADSHEET)
-    {
-        // Align to top left corner, so the tiles are in sync with the
-        // row/column bar, even when zooming out enough that not all space is
-        // used.
-        gtk_widget_set_halign(GTK_WIDGET(pDocView), GTK_ALIGN_START);
-        gtk_widget_set_valign(GTK_WIDGET(pDocView), GTK_ALIGN_START);
-    }
-
     initWindow(rWindow);
 }
 
@@ -2182,7 +2175,6 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
     g_aWindows[pWindow] = rWindow;
 
     g_signal_connect(rWindow.m_pDocView, "configure-event", G_CALLBACK(TiledRowColumnBar::docConfigureEvent), 0);
-    g_signal_connect(rWindow.m_pDocView, "configure-event", G_CALLBACK(CommentsSidebar::docConfigureEvent), 0);
     return pWindow;
 }
 


More information about the Libreoffice-commits mailing list