bump product version to 6.4.0.3
[LibreOffice.git] / libreofficekit / qa / gtktiledviewer / gtv-helpers.hxx
blobcc686bfdfdd4739956e51aa3f63bea7c77afdd39
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #ifndef GTV_HELPERS_H
11 #define GTV_HELPERS_H
13 #include <gtk/gtk.h>
15 #include "gtv-signal-handlers.hxx"
17 #include <map>
18 #include <string>
19 #include <memory>
21 #include <boost/property_tree/json_parser.hpp>
23 #define UI_FILE_NAME "gtv.ui"
25 // Wrapper with custom deleter to use for Gtk objects
26 template <class T>
27 using GtvGtkWrapper = std::unique_ptr<T, void(*)(T*)>;
29 namespace GtvHelpers
31 void userPromptDialog(GtkWindow* pWindow, const std::string& aTitle, std::map<std::string, std::string>& aEntries);
33 void clipboardSetHtml(GtkClipboard* pClipboard, const char* pSelection);
35 /// Generate an author string for multiple views.
36 std::string getNextAuthor();
38 GtkWidget* createCommentBox(const boost::property_tree::ptree& aComment);
40 std::string getDirPath(const std::string& filePath);
42 template<typename T>
43 std::vector<T> split(const std::string& aPayload, const std::string& aDelim, const int nItems)
45 std::vector<T> aRet;
47 if (!aPayload.empty())
49 gchar** ppCoordinates = g_strsplit(aPayload.c_str(), aDelim.c_str(), nItems);
50 gchar** ppCoordinate = ppCoordinates;
51 while (*ppCoordinate)
53 std::stringstream strstream(*ppCoordinate);
54 T item;
55 strstream >> item;
56 aRet.push_back(item);
57 ++ppCoordinate;
59 g_strfreev(ppCoordinates);
62 return aRet;
66 #endif
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */