1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:47:46 +00:00

LibGUI: Put all classes in the GUI namespace and remove the leading G

This took me a moment. Welcome to the new world of GUI::Widget! :^)
This commit is contained in:
Andreas Kling 2020-02-02 15:07:41 +01:00
parent 2d39da5405
commit c5bd9d4ed1
337 changed files with 5400 additions and 4816 deletions

View file

@ -48,7 +48,7 @@ ManualModel::ManualModel()
m_page_icon.set_bitmap_for_size(16, load_png("/res/icons/16x16/filetype-unknown.png"));
}
String ManualModel::page_path(const GModelIndex& index) const
String ManualModel::page_path(const GUI::ModelIndex& index) const
{
if (!index.is_valid())
return {};
@ -59,7 +59,7 @@ String ManualModel::page_path(const GModelIndex& index) const
return page->path();
}
String ManualModel::page_and_section(const GModelIndex& index) const
String ManualModel::page_and_section(const GUI::ModelIndex& index) const
{
if (!index.is_valid())
return {};
@ -71,7 +71,7 @@ String ManualModel::page_and_section(const GModelIndex& index) const
return String::format("%s(%s)", page->name().characters(), section->section_name().characters());
}
GModelIndex ManualModel::index(int row, int column, const GModelIndex& parent_index) const
GUI::ModelIndex ManualModel::index(int row, int column, const GUI::ModelIndex& parent_index) const
{
if (!parent_index.is_valid())
return create_index(row, column, &s_sections[row]);
@ -80,7 +80,7 @@ GModelIndex ManualModel::index(int row, int column, const GModelIndex& parent_in
return create_index(row, column, child);
}
GModelIndex ManualModel::parent_index(const GModelIndex& index) const
GUI::ModelIndex ManualModel::parent_index(const GUI::ModelIndex& index) const
{
if (!index.is_valid())
return {};
@ -103,7 +103,7 @@ GModelIndex ManualModel::parent_index(const GModelIndex& index) const
ASSERT_NOT_REACHED();
}
int ManualModel::row_count(const GModelIndex& index) const
int ManualModel::row_count(const GUI::ModelIndex& index) const
{
if (!index.is_valid())
return sizeof(s_sections) / sizeof(s_sections[0]);
@ -111,12 +111,12 @@ int ManualModel::row_count(const GModelIndex& index) const
return node->children().size();
}
int ManualModel::column_count(const GModelIndex&) const
int ManualModel::column_count(const GUI::ModelIndex&) const
{
return 1;
}
GVariant ManualModel::data(const GModelIndex& index, Role role) const
GUI::Variant ManualModel::data(const GUI::ModelIndex& index, Role role) const
{
auto* node = static_cast<const ManualNode*>(index.internal_data());
switch (role) {

View file

@ -30,7 +30,7 @@
#include <AK/String.h>
#include <LibGUI/GModel.h>
class ManualModel final : public GModel {
class ManualModel final : public GUI::Model {
public:
static NonnullRefPtr<ManualModel> create()
{
@ -39,15 +39,15 @@ public:
virtual ~ManualModel() override {};
String page_path(const GModelIndex&) const;
String page_and_section(const GModelIndex&) const;
String page_path(const GUI::ModelIndex&) const;
String page_and_section(const GUI::ModelIndex&) const;
virtual int row_count(const GModelIndex& = GModelIndex()) const override;
virtual int column_count(const GModelIndex& = GModelIndex()) const override;
virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override;
virtual void update() override;
virtual GModelIndex parent_index(const GModelIndex&) const override;
virtual GModelIndex index(int row, int column = 0, const GModelIndex& parent = GModelIndex()) const override;
virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override;
virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& parent = GUI::ModelIndex()) const override;
private:
ManualModel();

View file

@ -55,7 +55,7 @@ int main(int argc, char* argv[])
return 1;
}
GApplication app(argc, argv);
GUI::Application app(argc, argv);
if (pledge("stdio shared_buffer accept rpath", nullptr) < 0) {
perror("pledge");
@ -74,31 +74,31 @@ int main(int argc, char* argv[])
unveil(nullptr, nullptr);
auto window = GWindow::construct();
auto window = GUI::Window::construct();
window->set_title("Help");
window->set_rect(300, 200, 570, 500);
auto widget = GWidget::construct();
widget->set_layout(make<GVBoxLayout>());
auto widget = GUI::Widget::construct();
widget->set_layout(make<GUI::VBoxLayout>());
widget->layout()->set_spacing(0);
auto toolbar = GToolBar::construct(widget);
auto toolbar = GUI::ToolBar::construct(widget);
auto splitter = GSplitter::construct(Orientation::Horizontal, widget);
auto splitter = GUI::Splitter::construct(Orientation::Horizontal, widget);
auto model = ManualModel::create();
auto tree_view = GTreeView::construct(splitter);
auto tree_view = GUI::TreeView::construct(splitter);
tree_view->set_model(model);
tree_view->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
tree_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
tree_view->set_preferred_size(200, 500);
auto html_view = HtmlView::construct(splitter);
History history;
RefPtr<GAction> go_back_action;
RefPtr<GAction> go_forward_action;
RefPtr<GUI::Action> go_back_action;
RefPtr<GUI::Action> go_forward_action;
auto update_actions = [&]() {
go_back_action->set_enabled(history.can_go_back());
@ -118,7 +118,7 @@ int main(int argc, char* argv[])
if (!file->open(Core::IODevice::OpenMode::ReadOnly)) {
int saved_errno = errno;
GMessageBox::show(strerror(saved_errno), "Failed to open man page", GMessageBox::Type::Error, GMessageBox::InputType::OK, window);
GUI::MessageBox::show(strerror(saved_errno), "Failed to open man page", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window);
return;
}
auto buffer = file->read_all();
@ -158,13 +158,13 @@ int main(int argc, char* argv[])
free(path);
};
go_back_action = GCommonActions::make_go_back_action([&](auto&) {
go_back_action = GUI::CommonActions::make_go_back_action([&](auto&) {
history.go_back();
update_actions();
open_page(history.current());
});
go_forward_action = GCommonActions::make_go_forward_action([&](auto&) {
go_forward_action = GUI::CommonActions::make_go_forward_action([&](auto&) {
history.go_forward();
update_actions();
open_page(history.current());
@ -176,19 +176,19 @@ int main(int argc, char* argv[])
toolbar->add_action(*go_back_action);
toolbar->add_action(*go_forward_action);
auto menubar = make<GMenuBar>();
auto menubar = make<GUI::MenuBar>();
auto app_menu = GMenu::construct("Help");
app_menu->add_action(GAction::create("About", [&](const GAction&) {
GAboutDialog::show("Help", load_png("/res/icons/16x16/book.png"), window);
auto app_menu = GUI::Menu::construct("Help");
app_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
GUI::AboutDialog::show("Help", load_png("/res/icons/16x16/book.png"), window);
}));
app_menu->add_separator();
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
GApplication::the().quit(0);
app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
GUI::Application::the().quit(0);
}));
menubar->add_menu(move(app_menu));
auto go_menu = GMenu::construct("Go");
auto go_menu = GUI::Menu::construct("Go");
go_menu->add_action(*go_back_action);
go_menu->add_action(*go_forward_action);
menubar->add_menu(move(go_menu));