summaryrefslogtreecommitdiff
path: root/adw/src/actionrow.cpp
blob: f45f7a3c0ab2265ef34f47a91d8fe1e0a145223b (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include "turns/adw/actionrow.hpp"

#include "turns/adw/preferencesrow.hpp"

#include <glibmm/class.h>
#include <glibmm/object.h>
#include <glibmm/objectbase.h>
#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
#include <glibmm/utility.h>
#include <glibmm/wrap.h>

#include <gtkmm/init.h>
#include <gtkmm/listboxrow.h>
#include <gtkmm/private/widget_p.h>

#include <adwaita.h>
#include <glib-object.h>
#include <gtk/gtk.h>

namespace turns::adw
{
  namespace
  {
    auto constinit _class = ActionRow::Class{};
  }  // namespace

  auto ActionRow::Class::init() -> Glib::Class const &
  {
    if (!gtype_)
    {
      class_init_func_ = &ActionRow::Class::class_init_function;
      register_derived_type(adw_action_row_get_type());
    }
    return *this;
  }

  auto ActionRow::Class::class_init_function(void * gclass, void * data) -> void
  {
    auto const klass = static_cast<AdwActionRowClass *>(gclass);
    PreferencesRow::Class::class_init_function(klass, data);
  }

  auto ActionRow::Class::wrap_new(GObject * object) -> Glib::ObjectBase *
  {
    return new ActionRow(ADW_ACTION_ROW(object));
  }

  auto ActionRow::get_type() -> GType
  {
    return _class.init().get_type();
  }

  auto ActionRow::get_base_type() -> GType
  {
    return adw_action_row_get_type();
  }

  ActionRow::ActionRow()
      : Glib::ObjectBase{nullptr}
      , adw::PreferencesRow{Glib::ConstructParams{_class.init()}}
  {
  }

  auto ActionRow::add_prefix(Gtk::Widget & widget) -> ActionRow &
  {
    adw_action_row_add_prefix(Glib::unwrap(this), Glib::unwrap(&widget));
    return *this;
  }

  auto ActionRow::add_suffix(Gtk::Widget & widget) -> ActionRow &
  {
    adw_action_row_add_suffix(Glib::unwrap(this), Glib::unwrap(&widget));
    return *this;
  }

  auto ActionRow::remove(Gtk::Widget & widget) -> ActionRow &
  {
    adw_action_row_remove(Glib::unwrap(this), Glib::unwrap(&widget));
    return *this;
  }

  auto ActionRow::set_activatable_widget(Gtk::Widget & widget) noexcept -> CppObjectType &
  {
    adw_action_row_set_activatable_widget(Glib::unwrap(this), Glib::unwrap(&widget));
    return *this;
  }

  auto ActionRow::set_icon_name(Glib::ustring const & name) -> CppObjectType &
  {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
    adw_action_row_set_icon_name(Glib::unwrap(this), name.c_str());
#pragma GCC diagnostic pop
    return *this;
  }

  auto ActionRow::set_subtitle(Glib::ustring const & subtitle) -> CppObjectType &
  {
    adw_action_row_set_subtitle(Glib::unwrap(this), subtitle.c_str());
    return *this;
  }

  auto ActionRow::set_subtitle_lines(int subtitle_lines) noexcept -> CppObjectType &
  {
    adw_action_row_set_subtitle_lines(Glib::unwrap(this), subtitle_lines);
    return *this;
  }

  auto ActionRow::set_subtitle_selectable(bool subtitle_selectable) noexcept -> CppObjectType &
  {
    adw_action_row_set_subtitle_selectable(Glib::unwrap(this), subtitle_selectable);
    return *this;
  }

  auto ActionRow::set_title_lines(int title_lines) noexcept -> CppObjectType &
  {
    adw_action_row_set_title_lines(Glib::unwrap(this), title_lines);
    return *this;
  }

  ActionRow::ActionRow(Glib::ConstructParams const & params)
      : adw::PreferencesRow{params}
  {
  }

  ActionRow::ActionRow(BaseObjectType * gobj)
      : Glib::ObjectBase{nullptr}
      , adw::PreferencesRow(ADW_PREFERENCES_ROW(gobj))
  {
  }

}  // namespace turns::adw

namespace Glib
{
  auto wrap(AdwActionRow * object, bool copy) -> Glib::RefPtr<turns::adw::ActionRow>
  {
    return Glib::make_refptr_for_instance<turns::adw::ActionRow>(
        dynamic_cast<turns::adw::ActionRow *>(Glib::wrap_auto(G_OBJECT(object), copy)));
  }
}  // namespace Glib