Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
b3178e2f
Kaydet (Commit)
b3178e2f
authored
Ock 25, 2017
tarafından
Pranav Kant
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
lokdocview: 'comment' signal for comment callbacks
Change-Id: I82040893added83ff13395db3917b230ef6b01d5
üst
8b3ea2ad
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
16 deletions
+98
-16
gtktiledviewer.cxx
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+62
-16
lokdocview.cxx
libreofficekit/source/gtk/lokdocview.cxx
+36
-0
No files found.
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
Dosyayı görüntüle @
b3178e2f
...
...
@@ -51,6 +51,8 @@ public:
/// top level container for all comments in the sidebar
GtkWidget
*
m_pCommentsVBox
;
/// Prepare and return a comment object (GtkBox)
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
...
...
@@ -238,6 +240,35 @@ static void lcl_registerToolItem(TiledWindow& rWindow, GtkToolItem* pItem, const
rWindow
.
m_aToolItemSensitivities
[
pItem
]
=
true
;
}
GtkWidget
*
CommentsSidebar
::
createCommentBox
(
const
boost
::
property_tree
::
ptree
&
aComment
)
{
GtkWidget
*
pCommentVBox
=
gtk_box_new
(
GTK_ORIENTATION_VERTICAL
,
1
);
int
*
id
=
g_new
(
int
,
1
);
*
id
=
aComment
.
get
<
int
>
(
"id"
);
g_object_set_data_full
(
G_OBJECT
(
pCommentVBox
),
"id"
,
id
,
g_free
);
GtkWidget
*
pCommentText
=
gtk_label_new
(
aComment
.
get
<
std
::
string
>
(
"text"
).
c_str
());
GtkWidget
*
pCommentAuthor
=
gtk_label_new
(
aComment
.
get
<
std
::
string
>
(
"author"
).
c_str
());
GtkWidget
*
pCommentDate
=
gtk_label_new
(
aComment
.
get
<
std
::
string
>
(
"dateTime"
).
c_str
());
GtkWidget
*
pControlsHBox
=
gtk_box_new
(
GTK_ORIENTATION_HORIZONTAL
,
0
);
GtkWidget
*
pGotoButton
=
gtk_button_new_with_label
(
"Goto"
);
GtkWidget
*
pReplyButton
=
gtk_button_new_with_label
(
"Reply"
);
gtk_container_add
(
GTK_CONTAINER
(
pControlsHBox
),
pGotoButton
);
gtk_container_add
(
GTK_CONTAINER
(
pControlsHBox
),
pReplyButton
);
GtkWidget
*
pCommentSeparator
=
gtk_separator_new
(
GTK_ORIENTATION_HORIZONTAL
);
gtk_container_add
(
GTK_CONTAINER
(
pCommentVBox
),
pCommentText
);
gtk_container_add
(
GTK_CONTAINER
(
pCommentVBox
),
pCommentAuthor
);
gtk_container_add
(
GTK_CONTAINER
(
pCommentVBox
),
pCommentDate
);
gtk_container_add
(
GTK_CONTAINER
(
pCommentVBox
),
pControlsHBox
);
gtk_container_add
(
GTK_CONTAINER
(
pCommentVBox
),
pCommentSeparator
);
gtk_label_set_line_wrap
(
GTK_LABEL
(
pCommentText
),
TRUE
);
gtk_label_set_max_width_chars
(
GTK_LABEL
(
pCommentText
),
35
);
return
pCommentVBox
;
}
void
CommentsSidebar
::
unoViewAnnotations
(
GtkWidget
*
pWidget
,
gpointer
/*userdata*/
)
{
TiledWindow
&
rWindow
=
lcl_getTiledWindow
(
pWidget
);
...
...
@@ -250,7 +281,8 @@ void CommentsSidebar::unoViewAnnotations(GtkWidget* pWidget, gpointer /*userdata
gtk_widget_destroy
(
rWindow
.
m_pCommentsSidebar
->
m_pCommentsVBox
);
rWindow
.
m_pCommentsSidebar
->
m_pCommentsVBox
=
gtk_box_new
(
GTK_ORIENTATION_VERTICAL
,
2
);
rWindow
.
m_pCommentsSidebar
->
m_pCommentsVBox
=
gtk_grid_new
();
g_object_set
(
rWindow
.
m_pCommentsSidebar
->
m_pCommentsVBox
,
"orientation"
,
GTK_ORIENTATION_VERTICAL
,
nullptr
);
gtk_container_add
(
GTK_CONTAINER
(
rWindow
.
m_pCommentsSidebar
->
m_pMainVBox
),
rWindow
.
m_pCommentsSidebar
->
m_pCommentsVBox
);
boost
::
property_tree
::
ptree
aTree
;
...
...
@@ -259,21 +291,8 @@ void CommentsSidebar::unoViewAnnotations(GtkWidget* pWidget, gpointer /*userdata
{
for
(
boost
::
property_tree
::
ptree
::
value_type
&
rValue
:
aTree
.
get_child
(
"comments"
))
{
GtkWidget
*
pCommentVBox
=
gtk_box_new
(
GTK_ORIENTATION_VERTICAL
,
1
);
gtk_container_add
(
GTK_CONTAINER
(
rWindow
.
m_pCommentsSidebar
->
m_pCommentsVBox
),
pCommentVBox
);
GtkWidget
*
pCommentText
=
gtk_label_new
(
rValue
.
second
.
get
<
std
::
string
>
(
"text"
).
c_str
());
GtkWidget
*
pCommentAuthor
=
gtk_label_new
(
rValue
.
second
.
get
<
std
::
string
>
(
"author"
).
c_str
());
GtkWidget
*
pCommentDate
=
gtk_label_new
(
rValue
.
second
.
get
<
std
::
string
>
(
"dateTime"
).
c_str
());
GtkWidget
*
pCommentSeparator
=
gtk_separator_new
(
GTK_ORIENTATION_HORIZONTAL
);
gtk_container_add
(
GTK_CONTAINER
(
pCommentVBox
),
pCommentText
);
gtk_container_add
(
GTK_CONTAINER
(
pCommentVBox
),
pCommentAuthor
);
gtk_container_add
(
GTK_CONTAINER
(
pCommentVBox
),
pCommentDate
);
gtk_container_add
(
GTK_CONTAINER
(
pCommentVBox
),
pCommentSeparator
);
gtk_label_set_line_wrap
(
GTK_LABEL
(
pCommentText
),
TRUE
);
gtk_label_set_max_width_chars
(
GTK_LABEL
(
pCommentText
),
35
);
GtkWidget
*
pCommentBox
=
CommentsSidebar
::
createCommentBox
(
rValue
.
second
);
gtk_container_add
(
GTK_CONTAINER
(
rWindow
.
m_pCommentsSidebar
->
m_pCommentsVBox
),
pCommentBox
);
}
gtk_widget_show_all
(
rWindow
.
m_pCommentsSidebar
->
m_pCommentsVBox
);
}
...
...
@@ -305,6 +324,8 @@ gboolean CommentsSidebar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfigu
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
));
}
}
...
...
@@ -1429,6 +1450,30 @@ static void passwordRequired(LOKDocView* pLOKDocView, gchar* pUrl, gboolean bMod
gtk_widget_destroy
(
pPasswordDialog
);
}
static
void
commentCallback
(
LOKDocView
*
pLOKDocView
,
gchar
*
pComment
,
gpointer
/* pData */
)
{
TiledWindow
&
rWindow
=
lcl_getTiledWindow
(
GTK_WIDGET
(
pLOKDocView
));
std
::
stringstream
aStream
(
pComment
);
boost
::
property_tree
::
ptree
aRoot
;
boost
::
property_tree
::
read_json
(
aStream
,
aRoot
);
boost
::
property_tree
::
ptree
aComment
=
aRoot
.
get_child
(
"comment"
);
gtk_container_foreach
(
GTK_CONTAINER
(
rWindow
.
m_pCommentsSidebar
->
m_pCommentsVBox
),
[](
GtkWidget
*
pWidget
,
gpointer
userdata
)
{
boost
::
property_tree
::
ptree
*
pTree
=
static_cast
<
boost
::
property_tree
::
ptree
*>
(
userdata
);
int
*
id
=
static_cast
<
int
*>
(
g_object_get_data
(
G_OBJECT
(
pWidget
),
"id"
));
GtkWidget
*
pCommentsGrid
=
gtk_widget_get_parent
(
pWidget
);
if
(
*
id
==
pTree
->
get
<
int
>
(
"parent"
))
{
GtkWidget
*
pCommentBox
=
CommentsSidebar
::
createCommentBox
(
*
pTree
);
gtk_grid_insert_next_to
(
GTK_GRID
(
pCommentsGrid
),
pWidget
,
GTK_POS_BOTTOM
);
gtk_grid_attach_next_to
(
GTK_GRID
(
pCommentsGrid
),
pCommentBox
,
pWidget
,
GTK_POS_BOTTOM
,
1
,
1
);
gtk_widget_show_all
(
pCommentBox
);
}
}
,
&
aComment
);
}
static
void
toggleToolItem
(
GtkWidget
*
pWidget
,
gpointer
/*pData*/
)
{
TiledWindow
&
rWindow
=
lcl_getTiledWindow
(
pWidget
);
...
...
@@ -2014,6 +2059,7 @@ static void setupDocView(GtkWidget* pDocView)
g_signal_connect
(
pDocView
,
"cursor-changed"
,
G_CALLBACK
(
cursorChanged
),
nullptr
);
g_signal_connect
(
pDocView
,
"formula-changed"
,
G_CALLBACK
(
formulaChanged
),
nullptr
);
g_signal_connect
(
pDocView
,
"password-required"
,
G_CALLBACK
(
passwordRequired
),
nullptr
);
g_signal_connect
(
pDocView
,
"comment"
,
G_CALLBACK
(
commentCallback
),
nullptr
);
}
int
main
(
int
argc
,
char
*
argv
[]
)
...
...
libreofficekit/source/gtk/lokdocview.cxx
Dosyayı görüntüle @
b3178e2f
...
...
@@ -276,6 +276,7 @@ enum
FORMULA_CHANGED
,
TEXT_SELECTION
,
PASSWORD_REQUIRED
,
COMMENT
,
LAST_SIGNAL
};
...
...
@@ -1399,6 +1400,7 @@ callback (gpointer pData)
break
;
}
case
LOK_CALLBACK_COMMENT
:
g_signal_emit
(
pCallback
->
m_pDocView
,
doc_view_signals
[
COMMENT
],
0
,
pCallback
->
m_aPayload
.
c_str
());
break
;
default
:
g_assert
(
false
);
...
...
@@ -3105,6 +3107,40 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
G_TYPE_NONE
,
2
,
G_TYPE_STRING
,
G_TYPE_BOOLEAN
);
/**
* LOKDocView::comment:
* @pDocView: the #LOKDocView on which the signal is emitted
* @pComment: the JSON string containing comment notification
* The has following structure containing the information telling whether
* the comment has been added, deleted or modified.
* The example:
* {
* "comment": {
* "action": "Add",
* "id": "11",
* "parent": "4",
* "author": "Unknown Author",
* "text": "This is a comment",
* "dateTime": "2016-08-18T13:13:00",
* "anchorPos": "4529, 3906",
* "textRange": "1418, 3906, 3111, 919"
* }
* }
* 'action' can be 'Add', 'Remove' or 'Modify' depending on whether
* comment has been added, removed or modified.
* 'parent' is a non-zero comment id if this comment is a reply comment,
* otherwise its a root comment.
*/
doc_view_signals
[
COMMENT
]
=
g_signal_new
(
"comment"
,
G_TYPE_FROM_CLASS
(
pGObjectClass
),
G_SIGNAL_RUN_FIRST
,
0
,
nullptr
,
nullptr
,
g_cclosure_marshal_generic
,
G_TYPE_NONE
,
1
,
G_TYPE_STRING
);
}
SAL_DLLPUBLIC_EXPORT
GtkWidget
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment