summaryrefslogtreecommitdiff
path: root/adw/src/dialog.cpp
blob: 868ad229d96e2d13b71f720a840f72c1b9abfbc5 (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
143
144
145
146
#include "turns/adw/dialog.hpp"

#include "turns/adw/breakpoint.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/object.h>
#include <gtkmm/private/widget_p.h>
#include <gtkmm/widget.h>

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

namespace turns::adw
{

  namespace
  {
    auto constinit _class = Dialog::Class{};
  }  // namespace

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

  auto Dialog::Class::class_init_function(void * gclass, void * data) -> void
  {
    auto const klass = static_cast<BaseClassType *>(gclass);
    CppClassParent::class_init_function(klass, data);
  }

  auto Dialog::Class::wrap_new(GObject * object) -> Glib::ObjectBase *
  {
    return Gtk::manage(new Dialog(ADW_DIALOG(object)));
  }

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

  auto Dialog::get_base_type() -> GType
  {
    return adw_dialog_get_type();
  }

  Dialog::Dialog(Glib::ConstructParams const & params)
      : Gtk::Widget{params}
  {
  }

  Dialog::Dialog(AdwDialog * gobj)
      : Gtk::Widget(GTK_WIDGET(gobj))
  {
  }

  Dialog::Dialog()
      : Glib::ObjectBase{nullptr}
      , Gtk::Widget{Glib::ConstructParams{_class.init()}}
  {
  }

  auto Dialog::add_breakpoint(Glib::RefPtr<Breakpoint> const & breakpoint) -> void
  {
    // Take a copy because the dialog will take ownership of the breakpoint.
    adw_dialog_add_breakpoint(Glib::unwrap(this), Glib::unwrap_copy(breakpoint));
  }

  auto Dialog::close() -> void
  {
    adw_dialog_close(Glib::unwrap(this));
  }

  auto Dialog::force_close() -> void
  {
    adw_dialog_force_close(Glib::unwrap(this));
  }

  auto Dialog::get_can_close() const -> bool
  {
    return adw_dialog_get_can_close(const_cast<BaseObjectType *>(Glib::unwrap(this)));
  }

  auto Dialog::get_child() const -> Gtk::Widget *
  {
    return Glib::wrap(adw_dialog_get_child(const_cast<BaseObjectType *>(Glib::unwrap(this))), true);
  }

  auto Dialog::get_content_height() const -> int
  {
    return adw_dialog_get_content_height(const_cast<BaseObjectType *>(Glib::unwrap(this)));
  }

  auto Dialog::get_content_width() const -> int
  {
    return adw_dialog_get_content_width(const_cast<BaseObjectType *>(Glib::unwrap(this)));
  }

  auto Dialog::get_current_breakpoint() const -> Glib::RefPtr<Breakpoint>
  {
    return Glib::wrap(adw_dialog_get_current_breakpoint(const_cast<BaseObjectType *>(Glib::unwrap(this))), true);
  }

  auto Dialog::get_default_widget() const -> Gtk::Widget *
  {
    return Glib::wrap(adw_dialog_get_default_widget(const_cast<BaseObjectType *>(Glib::unwrap(this))));
  }

  auto Dialog::get_focus() const -> Gtk::Widget *
  {
    return Glib::wrap(adw_dialog_get_focus(const_cast<BaseObjectType *>(Glib::unwrap(this))));
  }

  auto Dialog::present(Gtk::Widget * parent) -> void
  {
    adw_dialog_present(Glib::unwrap(this), Glib::unwrap(parent));
  }

  auto Dialog::set_title(Glib::ustring const & str) -> void
  {
    adw_dialog_set_title(Glib::unwrap(this), Glib::c_str_or_nullptr(str));
  }

}  // namespace turns::adw

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