[Libreoffice-commits] core.git: Branch 'feature/lok_dialog' - 2 commits - libreofficekit/qa libreofficekit/source
Pranav Kant
pranavk at collabora.co.uk
Fri Jul 28 18:17:39 UTC 2017
libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx | 48 ++++++++++
libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx | 6 +
libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx | 19 +++
libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx | 2
libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx | 11 ++
libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx | 1
libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx | 10 ++
libreofficekit/source/gtk/lokdocview.cxx | 18 +++
8 files changed, 110 insertions(+), 5 deletions(-)
New commits:
commit 58ed58680ac200304087833f4491ec6f577153a2
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Fri Jul 28 23:45:25 2017 +0530
lokdialog: Queue a redraw on invalidation in gtktiledviewer
Change-Id: I081508674a71c3beb89175e4f8ac3256e6bc6c6a
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
index fbe5746ddf1e..ab28f23578ec 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
@@ -36,6 +36,8 @@ struct GtvApplicationWindowPrivate
gboolean toolbarBroadcast;
gboolean partSelectorBroadcast;
+ GList* m_pChildWindows;
+
// Rendering args; options with which lokdocview was rendered in this window
GtvRenderingArgs* m_pRenderingArgs;
};
@@ -105,6 +107,7 @@ gtv_application_window_init(GtvApplicationWindow* win)
gtk_container_add(GTK_CONTAINER(win), priv->container);
+ priv->m_pChildWindows = nullptr;
priv->m_pRenderingArgs = new GtvRenderingArgs();
}
@@ -311,6 +314,7 @@ static void setupDocView(GtvApplicationWindow* window)
g_signal_connect(window->lokdocview, "formula-changed", G_CALLBACK(LOKDocViewSigHandlers::formulaChanged), nullptr);
g_signal_connect(window->lokdocview, "password-required", G_CALLBACK(LOKDocViewSigHandlers::passwordRequired), nullptr);
g_signal_connect(window->lokdocview, "comment", G_CALLBACK(LOKDocViewSigHandlers::comment), nullptr);
+ g_signal_connect(window->lokdocview, "dialog-invalidate", G_CALLBACK(LOKDocViewSigHandlers::dialogInvalidate), nullptr);
g_signal_connect(window->lokdocview, "configure-event", G_CALLBACK(LOKDocViewSigHandlers::configureEvent), nullptr);
}
@@ -394,6 +398,50 @@ gtv_application_window_get_part_broadcast(GtvApplicationWindow* window)
return priv->partSelectorBroadcast;
}
+void
+gtv_application_window_register_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin)
+{
+ GtvApplicationWindowPrivate* priv = getPrivate(window);
+ if (pChildWin)
+ priv->m_pChildWindows = g_list_append(priv->m_pChildWindows, pChildWin);
+}
+
+void
+gtv_application_window_unregister_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin)
+{
+ GtvApplicationWindowPrivate* priv = getPrivate(window);
+ if (pChildWin)
+ priv->m_pChildWindows = g_list_remove(priv->m_pChildWindows, pChildWin);
+}
+
+GtkWindow*
+gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, const gchar* pWinId)
+{
+ GtvApplicationWindowPrivate* priv = getPrivate(window);
+ GList* pIt = nullptr;
+ GtkWindow* ret = nullptr;
+ // For now, only dialogs are registered as child window
+ for (pIt = priv->m_pChildWindows; pIt != nullptr; pIt = pIt->next)
+ {
+ gchar* dialogId = nullptr;
+ g_object_get(G_OBJECT(pIt->data), "dialogid", &dialogId, nullptr);
+
+ // prepend .uno:
+ gchar* completeWinId = nullptr;
+ if (pWinId != nullptr)
+ {
+ completeWinId = g_strconcat(".uno:", pWinId, nullptr);
+ }
+
+ if (dialogId != nullptr && g_str_equal(dialogId, completeWinId))
+ {
+ ret = GTK_WINDOW(pIt->data);
+ break;
+ }
+ }
+ return ret;
+}
+
GtvApplicationWindow*
gtv_application_window_new(GtkApplication* app)
{
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx
index ec3b0666d76d..c16425566967 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx
@@ -99,6 +99,12 @@ void gtv_application_window_set_part_broadcast(GtvApplicationWindow* window, boo
gboolean gtv_application_window_get_part_broadcast(GtvApplicationWindow* window);
+void gtv_application_window_register_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin);
+
+void gtv_application_window_unregister_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin);
+
+GtkWindow* gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, const gchar* pWinId);
+
G_END_DECLS
#endif /* GTV_APPLICATION_WINDOW_H */
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index 5b48bd1b9ed7..a073198e5db3 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -23,6 +23,7 @@
struct GtvLokDialogPrivate
{
LOKDocView* lokdocview;
+ GtkWidget* pDialogDrawingArea;
gchar* dialogid;
};
@@ -68,11 +69,13 @@ gtv_lok_dialog_draw(GtkWidget* pDialogDrawingArea, cairo_t* pCairo, gpointer)
static void
gtv_lok_dialog_init(GtvLokDialog* dialog)
{
+ GtvLokDialogPrivate* priv = getPrivate(dialog);
+
GtkWidget* pContentArea = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
- GtkWidget* pDialogDrawingArea = gtk_drawing_area_new();
+ priv->pDialogDrawingArea = gtk_drawing_area_new();
- g_signal_connect(G_OBJECT(pDialogDrawingArea), "draw", G_CALLBACK(gtv_lok_dialog_draw), nullptr);
- gtk_container_add(GTK_CONTAINER(pContentArea), pDialogDrawingArea);
+ g_signal_connect(G_OBJECT(priv->pDialogDrawingArea), "draw", G_CALLBACK(gtv_lok_dialog_draw), nullptr);
+ gtk_container_add(GTK_CONTAINER(pContentArea), priv->pDialogDrawingArea);
}
static void
@@ -150,6 +153,14 @@ gtv_lok_dialog_class_init(GtvLokDialogClass* klass)
g_object_class_install_properties (G_OBJECT_CLASS(klass), PROP_LAST, properties);
}
+void
+gtv_lok_dialog_invalidate(GtvLokDialog* dialog)
+{
+ // trigger a draw on the drawing area
+ GtvLokDialogPrivate* priv = getPrivate(dialog);
+ gtk_widget_queue_draw(priv->pDialogDrawingArea);
+}
+
GtkWidget*
gtv_lok_dialog_new(LOKDocView* pDocView, const gchar* dialogId)
{
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx
index 650d816e7e4a..0205f2ede3f4 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx
@@ -37,6 +37,8 @@ GType gtv_lok_dialog_get_type (void) G_GNUC_CONST;
GtkWidget* gtv_lok_dialog_new(LOKDocView* pDocView, const gchar* dialogId);
+void gtv_lok_dialog_invalidate(GtvLokDialog* dialog);
+
G_END_DECLS
#endif /* GTV_LOK_DIALOG_H */
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
index 33f705262808..a549d852c786 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
@@ -15,6 +15,7 @@
#include <gtv-calc-header-bar.hxx>
#include <gtv-comments-sidebar.hxx>
#include <gtv-lokdocview-signal-handlers.hxx>
+#include <gtv-lok-dialog.hxx>
#include <boost/property_tree/json_parser.hpp>
#include <boost/optional.hpp>
@@ -280,6 +281,16 @@ void LOKDocViewSigHandlers::comment(LOKDocView* pDocView, gchar* pComment, gpoin
}
}
+void LOKDocViewSigHandlers::dialogInvalidate(LOKDocView* pDocView, gchar* pDialogId, gpointer)
+{
+ GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView)));
+ GtkWindow* pDialog = gtv_application_window_get_child_window_by_id(window, pDialogId);
+ if (pDialog)
+ {
+ gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pDialog));
+ }
+}
+
gboolean LOKDocViewSigHandlers::configureEvent(GtkWidget* pWidget, GdkEventConfigure* /*pEvent*/, gpointer /*pData*/)
{
GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pWidget)));
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx
index 724f2031d4f5..73bf9c2860ad 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx
@@ -25,6 +25,7 @@ namespace LOKDocViewSigHandlers {
void formulaChanged(LOKDocView* pDocView, char* pPayload, gpointer);
void passwordRequired(LOKDocView* pDocView, char* pUrl, gboolean bModify, gpointer);
void comment(LOKDocView* pDocView, gchar* pComment, gpointer);
+ void dialogInvalidate(LOKDocView* pDocView, gchar* pDialogId, gpointer);
gboolean configureEvent(GtkWidget* pWidget, GdkEventConfigure* pEvent, gpointer pData);
}
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
index 5b3b113d0a6e..7c86b283d497 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
@@ -282,11 +282,21 @@ void changePartMode( GtkWidget* pSelector, gpointer /* pItem */ )
}
}
+static gboolean deleteLokDialog(GtkWidget* pWidget, GdkEvent* /*event*/, gpointer userdata)
+{
+ GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(userdata);
+ gtv_application_window_unregister_child_window(window, GTK_WINDOW(pWidget));
+
+ return FALSE;
+}
+
void openLokDialog( GtkWidget* pSelector, gpointer /*pItem*/ )
{
GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(pSelector));
gchar* pDialogId = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(pSelector));
GtkWidget* pDialog = gtv_lok_dialog_new(LOK_DOC_VIEW(window->lokdocview), pDialogId);
+ gtv_application_window_register_child_window(window, GTK_WINDOW(pDialog));
+ g_signal_connect(pDialog, "delete-event", G_CALLBACK(deleteLokDialog), window);
g_free(pDialogId);
gtk_window_set_resizable(GTK_WINDOW(pDialog), false);
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 142202566a96..3ee8641c6472 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -278,6 +278,7 @@ enum
TEXT_SELECTION,
PASSWORD_REQUIRED,
COMMENT,
+ DIALOG_INVALIDATE,
LAST_SIGNAL
};
@@ -1425,7 +1426,7 @@ callback (gpointer pData)
g_signal_emit(pCallback->m_pDocView, doc_view_signals[COMMENT], 0, pCallback->m_aPayload.c_str());
break;
case LOK_CALLBACK_DIALOG_INVALIDATE:
- // TODO: Register the signal with lokdocview and emit it
+ g_signal_emit(pCallback->m_pDocView, doc_view_signals[DIALOG_INVALIDATE], 0, pCallback->m_aPayload.c_str());
break;
default:
g_assert(false);
@@ -3213,6 +3214,21 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
g_cclosure_marshal_generic,
G_TYPE_NONE, 1,
G_TYPE_STRING);
+
+ /**
+ * LOKDocView::dialog-invalidate:
+ * @pDocView: the #LOKDocView on which the signal is emitted
+ * @pDialogId: The uno command for the dialog (dialog ID)
+ */
+ doc_view_signals[DIALOG_INVALIDATE] =
+ g_signal_new("dialog-invalidate",
+ 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*
commit 198ddf28f4456dc3255cf4e6f78d189d73bbaa7d
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Fri Jul 28 23:45:19 2017 +0530
lokdialog: this is a string
Change-Id: I7cb320a740cdb21da5a654cf99c887f5c7a8979d
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index 31f16ae960b5..5b48bd1b9ed7 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -106,7 +106,7 @@ gtv_lok_dialog_get_property(GObject* object, guint propId, GValue* value, GParam
g_value_set_object(value, priv->lokdocview);
break;
case PROP_DIALOG_ID:
- g_value_set_pointer(value, priv->dialogid);
+ g_value_set_string(value, priv->dialogid);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propId, pspec);
More information about the Libreoffice-commits
mailing list