From 3900eebf15683d160047cb7ef7755fa6c1313ef2 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 29 Sep 2019 21:00:41 +0200 Subject: [PATCH] FileManager+LibGUI+html: Add an icon to represent HTML files This also becomes the app icon for the little "html" program. :^) --- Applications/FileManager/DirectoryView.cpp | 10 ++++++++++ Base/res/icons/16x16/filetype-html.png | Bin 0 -> 1478 bytes Base/res/icons/32x32/filetype-html.png | Bin 0 -> 454 bytes Libraries/LibGUI/GDirectoryModel.cpp | 3 +++ Libraries/LibGUI/GDirectoryModel.h | 1 + Userland/html.cpp | 22 +++++++++++++++++++++ 6 files changed, 36 insertions(+) create mode 100644 Base/res/icons/16x16/filetype-html.png create mode 100644 Base/res/icons/32x32/filetype-html.png diff --git a/Applications/FileManager/DirectoryView.cpp b/Applications/FileManager/DirectoryView.cpp index 326fae02ab..1243d3bee7 100644 --- a/Applications/FileManager/DirectoryView.cpp +++ b/Applications/FileManager/DirectoryView.cpp @@ -53,6 +53,16 @@ void DirectoryView::handle_activation(const GModelIndex& index) return; } + if (path.to_lowercase().ends_with(".html")) { + if (fork() == 0) { + int rc = execl("/bin/html", "/bin/html", path.characters(), nullptr); + if (rc < 0) + perror("exec"); + ASSERT_NOT_REACHED(); + } + return; + } + if (path.to_lowercase().ends_with(".wav")) { if (fork() == 0) { int rc = execl("/bin/SoundPlayer", "/bin/SoundPlayer", path.characters(), nullptr); diff --git a/Base/res/icons/16x16/filetype-html.png b/Base/res/icons/16x16/filetype-html.png new file mode 100644 index 0000000000000000000000000000000000000000..b6a0cc04938d033d4d6ed999b531ca7ad552fc00 GIT binary patch literal 1478 zcmV;%1v&bOP) zaB^>EX>4U6ba`-PAZ2)IW&i+q+SQj?cI_w(MgJK^4FO3sVmP#Gy&2T->wvkweUg{t zr|gvrma#Z!izcT3`)8Pca4}gm&PNR?1dGchmpG%M_PCCctXseP!CoqNc5}X9m;|L9 zkD>4O8FqjDAi8ZY_jVKO_M_VoosQQfv*%gg?Q}a5K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5OgvfkZ39W>X zKUn`1F!KSL=t5q2XImP~oh`luLg2}Ju#lS!3()Y2gX=pyoFB0#(1jceJRiqu9RMH| zCDO0I2+TB4wY)@d0I(Y_0ANq~K)o-KwTUnU=3+!u%fnl>oq5$PaE$Q7KpW wp9exB(eNMr?B{``kGWpWXf78Fur@e80ULUSzxtduGynhq07*qoM6N<$f~@SprvLx| literal 0 HcmV?d00001 diff --git a/Libraries/LibGUI/GDirectoryModel.cpp b/Libraries/LibGUI/GDirectoryModel.cpp index 978538250a..21955a03c5 100644 --- a/Libraries/LibGUI/GDirectoryModel.cpp +++ b/Libraries/LibGUI/GDirectoryModel.cpp @@ -34,6 +34,7 @@ GDirectoryModel::GDirectoryModel() m_executable_icon = GIcon::default_icon("filetype-executable"); m_filetype_image_icon = GIcon::default_icon("filetype-image"); m_filetype_sound_icon = GIcon::default_icon("filetype-sound"); + m_filetype_html_icon = GIcon::default_icon("filetype-html"); setpwent(); while (auto* passwd = getpwent()) @@ -159,6 +160,8 @@ GIcon GDirectoryModel::icon_for(const Entry& entry) const return m_executable_icon; if (entry.name.to_lowercase().ends_with(".wav")) return m_filetype_sound_icon; + if (entry.name.to_lowercase().ends_with(".html")) + return m_filetype_html_icon; if (entry.name.to_lowercase().ends_with(".png")) { if (!entry.thumbnail) { if (!const_cast(this)->fetch_thumbnail_for(entry)) diff --git a/Libraries/LibGUI/GDirectoryModel.h b/Libraries/LibGUI/GDirectoryModel.h index 2102bebb6f..5f7ac03049 100644 --- a/Libraries/LibGUI/GDirectoryModel.h +++ b/Libraries/LibGUI/GDirectoryModel.h @@ -78,6 +78,7 @@ private: GIcon m_executable_icon; GIcon m_filetype_image_icon; GIcon m_filetype_sound_icon; + GIcon m_filetype_html_icon; HashMap m_user_names; HashMap m_group_names; diff --git a/Userland/html.cpp b/Userland/html.cpp index 5a28f240a5..cff3afb1b0 100644 --- a/Userland/html.cpp +++ b/Userland/html.cpp @@ -1,5 +1,9 @@ #include +#include +#include #include +#include +#include #include #include #include @@ -48,5 +52,23 @@ int main(int argc, char** argv) window->set_main_widget(widget); window->show(); + auto menubar = make(); + + auto app_menu = make("HTML"); + app_menu->add_action(GCommonActions::make_quit_action([&](auto&) { + app.quit(); + })); + menubar->add_menu(move(app_menu)); + + auto help_menu = make("Help"); + help_menu->add_action(GAction::create("About", [&](const GAction&) { + GAboutDialog::show("HTML", GraphicsBitmap::load_from_file("/res/icons/32x32/filetype-html.png"), window); + })); + menubar->add_menu(move(help_menu)); + + app.set_menubar(move(menubar)); + + window->set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-html.png")); + return app.exec(); }