diff options
Diffstat (limited to 'libreofficekit')
3 files changed, 35 insertions, 49 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx index 176fa91fffaa..b5325cf853c0 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx @@ -48,7 +48,7 @@ struct GtvLokDialogPrivate guint32 m_nChildKeyModifier; guint32 m_nChildLastButtonPressed; - gchar* dialogid; + guint dialogid; }; G_DEFINE_TYPE_WITH_PRIVATE(GtvLokDialog, gtv_lok_dialog, GTK_TYPE_DIALOG); @@ -400,7 +400,7 @@ gtv_lok_dialog_set_property(GObject* object, guint propId, const GValue* value, priv->lokdocview = LOK_DOC_VIEW(g_value_get_object(value)); break; case PROP_DIALOG_ID: - priv->dialogid = g_value_dup_string(value); + priv->dialogid = g_value_get_uint(value); break; case PROP_DIALOG_WIDTH: priv->m_nWidth = g_value_get_uint(value); @@ -425,7 +425,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_string(value, priv->dialogid); + g_value_set_uint(value, priv->dialogid); break; case PROP_DIALOG_WIDTH: g_value_set_uint(value, priv->m_nWidth); @@ -439,22 +439,10 @@ gtv_lok_dialog_get_property(GObject* object, guint propId, GValue* value, GParam } static void -gtv_lok_dialog_finalize(GObject* object) -{ - GtvLokDialog* self = GTV_LOK_DIALOG(object); - GtvLokDialogPrivate* priv = getPrivate(self); - - g_free(priv->dialogid); - - G_OBJECT_CLASS(gtv_lok_dialog_parent_class)->finalize(object); -} - -static void gtv_lok_dialog_class_init(GtvLokDialogClass* klass) { G_OBJECT_CLASS(klass)->get_property = gtv_lok_dialog_get_property; G_OBJECT_CLASS(klass)->set_property = gtv_lok_dialog_set_property; - G_OBJECT_CLASS(klass)->finalize = gtv_lok_dialog_finalize; properties[PROP_LOKDOCVIEW_CONTEXT] = g_param_spec_object("lokdocview", "LOKDocView Context", @@ -464,29 +452,29 @@ gtv_lok_dialog_class_init(GtvLokDialogClass* klass) G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); - properties[PROP_DIALOG_ID] = g_param_spec_string("dialogid", - "Dialog identifier", - "Unique dialog identifier; UNO command for now", - nullptr, - static_cast<GParamFlags>(G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + properties[PROP_DIALOG_ID] = g_param_spec_uint("dialogid", + "Dialog identifier", + "Unique dialog identifier", + 0, G_MAXUINT, 0, + static_cast<GParamFlags>(G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); properties[PROP_DIALOG_WIDTH] = g_param_spec_uint("width", - "Dialog width", - "Dialog width", - 0, 1024, 0, - static_cast<GParamFlags>(G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + "Dialog width", + "Dialog width", + 0, 1024, 0, + static_cast<GParamFlags>(G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); properties[PROP_DIALOG_HEIGHT] = g_param_spec_uint("height", "Dialog height", - "Dialog height", - 0, 1024, 0, - static_cast<GParamFlags>(G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + "Dialog height", + 0, 1024, 0, + static_cast<GParamFlags>(G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); g_object_class_install_properties (G_OBJECT_CLASS(klass), PROP_LAST, properties); } @@ -702,7 +690,7 @@ void gtv_lok_dialog_child_close(GtvLokDialog* dialog) GtkWidget* -gtv_lok_dialog_new(LOKDocView* pDocView, const gchar* dialogId, guint width, guint height) +gtv_lok_dialog_new(LOKDocView* pDocView, guint dialogId, guint width, guint height) { GtkWindow* pWindow = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView))); return GTK_WIDGET(g_object_new(GTV_TYPE_LOK_DIALOG, diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx index 8f2161ef5f27..0f7002c359d7 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx @@ -35,7 +35,7 @@ struct GtvLokDialogClass GType gtv_lok_dialog_get_type (void) G_GNUC_CONST; -GtkWidget* gtv_lok_dialog_new(LOKDocView* pDocView, const gchar* dialogId, guint width, guint height); +GtkWidget* gtv_lok_dialog_new(LOKDocView* pDocView, guint dialogId, guint width, guint height); void gtv_lok_dialog_invalidate(GtvLokDialog* dialog, const GdkRectangle& aRectangle); diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx index 03e54afd1d22..62f639957d2b 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx @@ -308,15 +308,15 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint std::stringstream aStream(pPayload); boost::property_tree::ptree aRoot; boost::property_tree::read_json(aStream, aRoot); - const std::string aDialogId = aRoot.get<std::string>("dialogId"); + const unsigned nDialogId = aRoot.get<unsigned>("dialogId"); const std::string aAction = aRoot.get<std::string>("action"); if (aAction == "created") { const std::string aSize = aRoot.get<std::string>("size"); std::vector<int> aPoints = GtvHelpers::splitIntoIntegers(aSize, ", ", 2); - GtkWidget* pDialog = gtv_lok_dialog_new(pDocView, aDialogId.c_str(), aPoints[0], aPoints[1]); - g_info("created dialog, for dialogid: %s with size: %s", aDialogId.c_str(), aSize.c_str()); + GtkWidget* pDialog = gtv_lok_dialog_new(pDocView, nDialogId, aPoints[0], aPoints[1]); + g_info("created dialog, for dialogid: %d with size: %s", nDialogId, aSize.c_str()); gtv_application_window_register_child_window(window, GTK_WINDOW(pDialog)); g_signal_connect(pDialog, "destroy", G_CALLBACK(destroyLokDialog), window); @@ -333,9 +333,9 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint GList* pIt = nullptr; for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next) { - gchar* pChildDialogId = nullptr; - g_object_get(pIt->data, "dialogid", &pChildDialogId, nullptr); - if (g_strcmp0(pChildDialogId, aDialogId.c_str()) == 0) + guint nChildDialogId = 0; + g_object_get(pIt->data, "dialogid", &nChildDialogId, nullptr); + if (nDialogId == nChildDialogId) { if (aAction == "close") gtk_widget_destroy(GTK_WIDGET(pIt->data)); @@ -355,7 +355,6 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pIt->data), aGdkRectangle); } } - g_free(pChildDialogId); } } @@ -366,9 +365,9 @@ void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, g std::stringstream aStream(pPayload); boost::property_tree::ptree aRoot; boost::property_tree::read_json(aStream, aRoot); - std::string aDialogId = aRoot.get<std::string>("dialogId"); - std::string aAction = aRoot.get<std::string>("action"); - std::string aPos = aRoot.get<std::string>("position"); + const unsigned nDialogId = aRoot.get<unsigned>("dialogId"); + const std::string aAction = aRoot.get<std::string>("action"); + const std::string aPos = aRoot.get<std::string>("position"); gchar** ppCoordinates = g_strsplit(aPos.c_str(), ", ", 2); gchar** ppCoordinate = ppCoordinates; int nX = 0; @@ -386,16 +385,15 @@ void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, g GList* pIt = nullptr; for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next) { - gchar* pChildDialogId = nullptr; - g_object_get(pIt->data, "dialogid", &pChildDialogId, nullptr); - if (g_strcmp0(pChildDialogId, aDialogId.c_str()) == 0) + guint nChildDialogId = 0; + g_object_get(pIt->data, "dialogid", &nChildDialogId, nullptr); + if (nDialogId == nChildDialogId) { if (aAction == "invalidate") gtv_lok_dialog_child_invalidate(GTV_LOK_DIALOG(pIt->data), nX, nY); else if (aAction == "close") gtv_lok_dialog_child_close(GTV_LOK_DIALOG(pIt->data)); } - g_free(pChildDialogId); } } |