diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-09-29 21:00:41 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-09-29 21:00:41 +0200 |
commit | 3900eebf15683d160047cb7ef7755fa6c1313ef2 (patch) | |
tree | 2cbd7527ac76bb510b8d373081704c56f43c1955 | |
parent | e38b454e110d85c893e6cdc71fd71467562ec9c1 (diff) | |
download | serenity-3900eebf15683d160047cb7ef7755fa6c1313ef2.zip |
FileManager+LibGUI+html: Add an icon to represent HTML files
This also becomes the app icon for the little "html" program. :^)
-rw-r--r-- | Applications/FileManager/DirectoryView.cpp | 10 | ||||
-rw-r--r-- | Base/res/icons/16x16/filetype-html.png | bin | 0 -> 1478 bytes | |||
-rw-r--r-- | Base/res/icons/32x32/filetype-html.png | bin | 0 -> 454 bytes | |||
-rw-r--r-- | Libraries/LibGUI/GDirectoryModel.cpp | 3 | ||||
-rw-r--r-- | Libraries/LibGUI/GDirectoryModel.h | 1 | ||||
-rw-r--r-- | Userland/html.cpp | 22 |
6 files changed, 36 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 0000000000..b6a0cc0493 --- /dev/null +++ b/Base/res/icons/16x16/filetype-html.png diff --git a/Base/res/icons/32x32/filetype-html.png b/Base/res/icons/32x32/filetype-html.png Binary files differnew file mode 100644 index 0000000000..08a8bd90d9 --- /dev/null +++ b/Base/res/icons/32x32/filetype-html.png 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<GDirectoryModel*>(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<uid_t, String> m_user_names; HashMap<gid_t, String> 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 <LibCore/CFile.h> +#include <LibGUI/GAboutDialog.h> +#include <LibGUI/GAction.h> #include <LibGUI/GApplication.h> +#include <LibGUI/GMenu.h> +#include <LibGUI/GMenuBar.h> #include <LibGUI/GWindow.h> #include <LibHTML/CSS/StyleResolver.h> #include <LibHTML/DOM/Element.h> @@ -48,5 +52,23 @@ int main(int argc, char** argv) window->set_main_widget(widget); window->show(); + auto menubar = make<GMenuBar>(); + + auto app_menu = make<GMenu>("HTML"); + app_menu->add_action(GCommonActions::make_quit_action([&](auto&) { + app.quit(); + })); + menubar->add_menu(move(app_menu)); + + auto help_menu = make<GMenu>("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(); } |