summaryrefslogtreecommitdiff
path: root/gio/src/themedicon.hg
blob: d5a0ea2aba0b4b0a4029670e197b2a9ca918b37b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-

/* Copyright (C) 2007 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <glibmm/object.h>
#include <giomm/file.h>
#include <giomm/icon.h>
#include <giomm/loadableicon.h>

_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gio
{

/** Icon theming support
 * ThemedIcon is an implementation of Gio::Icon that supports icon themes.
 * ThemedIcon contains a list of all of the icons present in an icon
 * theme, so that icons can be looked up quickly. ThemedIcon does
 * not provide actual pixmaps for icons, just the icon names.
 * Ideally something like Gtk::IconTheme::choose_icon() should be used to
 * resolve the list of names so that fallback icons work nicely with
 * themes that inherit other themes.
 *
 * @newin{2,16}
 */
class ThemedIcon
: public Glib::Object,
  public Icon
{
  _CLASS_GOBJECT(ThemedIcon, GThemedIcon, G_THEMED_ICON, Glib::Object, GObject)
  _IMPLEMENTS_INTERFACE(Icon)

protected:
  /** Creates a new themed icon for @ iconname, and optionally all the names that can be created by shortening @a iconname at '-' characters.
   *
   * @param iconname A string containing an icon name.
   * @param use_default_callbacks Whether to use all the names that can be created by shortening @a iconname at '-' characters.
   */
  explicit ThemedIcon(const std::string& iconname, bool use_default_callbacks = false);
  _IGNORE(g_themed_icon_new, g_themed_icon_new_with_default_fallbacks)

public:
  /** Creates a new themed icon for @ iconname, and optionally all the names that can be created by shortening @a iconname at '-' characters.
   *
   * @param iconname A string containing an icon name.
   * @param use_default_callbacks Whether to use all the names that can be created by shortening @a iconname at '-' characters.
   */
  _WRAP_CREATE(const std::string& iconname, bool use_default_callbacks = false)

  //TODO: GIcon *g_themed_icon_new_from_names (char **iconnames, int len);

  _WRAP_METHOD(void prepend_name(const std::string& iconname), g_themed_icon_prepend_name)
  _WRAP_METHOD(void append_name(const std::string& iconname), g_themed_icon_append_name)

  #m4 _CONVERSION(`const gchar* const*',`Glib::StringArrayHandle',`Glib::StringArrayHandle($3, Glib::OWNERSHIP_DEEP)')
  _WRAP_METHOD(Glib::StringArrayHandle get_names() const, g_themed_icon_get_names)

  //There are no signals.

  //The "name" property is write-only and construct-only so it should not be wrapped.
  _WRAP_PROPERTY("names", std::vector<Glib::ustring>)
  _WRAP_PROPERTY("use-default-fallbacks", bool)
};

} // namespace Gio