tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / libreofficekit / qa / gtktiledviewer / gtv-helpers.hxx
blob4b304ab895cd3cc518bd3cf6d35e8610f5571e08
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 <map>
16 #include <sstream>
17 #include <string>
18 #include <vector>
19 #include <memory>
21 #include <boost/property_tree/ptree_fwd.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: */