summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-29 21:00:41 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-29 21:00:41 +0200
commit3900eebf15683d160047cb7ef7755fa6c1313ef2 (patch)
tree2cbd7527ac76bb510b8d373081704c56f43c1955
parente38b454e110d85c893e6cdc71fd71467562ec9c1 (diff)
downloadserenity-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.cpp10
-rw-r--r--Base/res/icons/16x16/filetype-html.pngbin0 -> 1478 bytes
-rw-r--r--Base/res/icons/32x32/filetype-html.pngbin0 -> 454 bytes
-rw-r--r--Libraries/LibGUI/GDirectoryModel.cpp3
-rw-r--r--Libraries/LibGUI/GDirectoryModel.h1
-rw-r--r--Userland/html.cpp22
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
new file mode 100644
index 0000000000..b6a0cc0493
--- /dev/null
+++ b/Base/res/icons/16x16/filetype-html.png
Binary files differ
diff --git a/Base/res/icons/32x32/filetype-html.png b/Base/res/icons/32x32/filetype-html.png
new file mode 100644
index 0000000000..08a8bd90d9
--- /dev/null
+++ b/Base/res/icons/32x32/filetype-html.png
Binary files differ
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();
}