summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
Diffstat (limited to 'Applications')
-rw-r--r--Applications/Clock/Makefile2
-rw-r--r--Applications/FileManager/DirectoryView.cpp21
-rw-r--r--Applications/FileManager/DirectoryView.h3
-rw-r--r--Applications/FileManager/Makefile2
-rw-r--r--Applications/FileManager/main.cpp18
-rw-r--r--Applications/FontEditor/Makefile2
-rw-r--r--Applications/Launcher/Makefile2
-rw-r--r--Applications/Terminal/Makefile2
8 files changed, 39 insertions, 13 deletions
diff --git a/Applications/Clock/Makefile b/Applications/Clock/Makefile
index 13d43b94f4..1939a1d220 100644
--- a/Applications/Clock/Makefile
+++ b/Applications/Clock/Makefile
@@ -23,7 +23,7 @@ LDFLAGS = -static --strip-debug -melf_i386 -e _start --gc-sections
all: $(APP)
$(APP): $(OBJS)
- $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../LibGUI/LibGUI.a ../LibC/LibC.a
+ $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../../LibGUI/LibGUI.a ../../LibC/LibC.a
.cpp.o:
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
diff --git a/Applications/FileManager/DirectoryView.cpp b/Applications/FileManager/DirectoryView.cpp
index c87d652e28..4ffc28feb6 100644
--- a/Applications/FileManager/DirectoryView.cpp
+++ b/Applications/FileManager/DirectoryView.cpp
@@ -53,6 +53,8 @@ void DirectoryView::reload()
}
m_directories.clear();
m_files.clear();
+
+ size_t bytes_in_files = 0;
while (auto* de = readdir(dirp)) {
Entry entry;
entry.name = de->d_name;
@@ -66,10 +68,21 @@ void DirectoryView::reload()
entry.mode = st.st_mode;
auto& entries = S_ISDIR(st.st_mode) ? m_directories : m_files;
entries.append(move(entry));
+
+ if (S_ISREG(entry.mode))
+ bytes_in_files += st.st_size;
}
closedir(dirp);
int excess_height = max(0, (item_count() * item_height()) - height());
m_scrollbar->set_range(0, excess_height);
+
+
+
+ set_status_message(String::format("%d item%s (%u byte%s)",
+ item_count(),
+ item_count() != 1 ? "s" : "",
+ bytes_in_files,
+ bytes_in_files != 1 ? "s" : ""));
}
const GraphicsBitmap& DirectoryView::icon_for(const Entry& entry) const
@@ -128,7 +141,7 @@ void DirectoryView::paint_event(GPaintEvent&)
Rect icon_rect(horizontal_padding, y, icon_size, item_height());
Rect name_rect(icon_rect.right() + horizontal_padding, y, 100, item_height());
Rect size_rect(name_rect.right() + horizontal_padding, y, 64, item_height());
- painter.fill_rect(row_rect(painted_item_index), i % 2 ? Color::LightGray : Color::White);
+ painter.fill_rect(row_rect(painted_item_index), i % 2 ? Color(210, 210, 210) : Color::White);
painter.blit_with_alpha(icon_rect.location(), icon_for(entry), { 0, 0, icon_size, icon_size });
painter.draw_text(name_rect, entry.name, Painter::TextAlignment::CenterLeft, Color::Black);
if (should_show_size_for(entry))
@@ -143,3 +156,9 @@ void DirectoryView::paint_event(GPaintEvent&)
unpainted_rect.intersect(rect());
painter.fill_rect(unpainted_rect, Color::White);
}
+
+void DirectoryView::set_status_message(String&& message)
+{
+ if (on_status_message)
+ on_status_message(move(message));
+}
diff --git a/Applications/FileManager/DirectoryView.h b/Applications/FileManager/DirectoryView.h
index cf6e1935ed..60bc82ebf0 100644
--- a/Applications/FileManager/DirectoryView.h
+++ b/Applications/FileManager/DirectoryView.h
@@ -15,6 +15,7 @@ public:
void reload();
Function<void(const String&)> on_path_change;
+ Function<void(String)> on_status_message;
int item_height() const { return 16; }
int item_count() const { return m_directories.size() + m_files.size(); }
@@ -24,6 +25,8 @@ private:
virtual void resize_event(GResizeEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
+ void set_status_message(String&&);
+
Rect row_rect(int item_index) const;
struct Entry {
diff --git a/Applications/FileManager/Makefile b/Applications/FileManager/Makefile
index 1fd1842e8e..f41a35cfca 100644
--- a/Applications/FileManager/Makefile
+++ b/Applications/FileManager/Makefile
@@ -23,7 +23,7 @@ LDFLAGS = -static --strip-debug -melf_i386 -e _start --gc-sections
all: $(APP)
$(APP): $(OBJS)
- $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../LibGUI/LibGUI.a ../LibC/LibC.a
+ $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../../LibGUI/LibGUI.a ../../LibC/LibC.a
.cpp.o:
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp
index e8bb846976..2bf781fccb 100644
--- a/Applications/FileManager/main.cpp
+++ b/Applications/FileManager/main.cpp
@@ -1,14 +1,10 @@
-#include <SharedGraphics/GraphicsBitmap.h>
#include <LibGUI/GWindow.h>
#include <LibGUI/GWidget.h>
-#include <LibGUI/GButton.h>
-#include <LibGUI/GListBox.h>
+#include <LibGUI/GBoxLayout.h>
#include <LibGUI/GEventLoop.h>
-#include <sys/wait.h>
-#include <signal.h>
+#include <LibGUI/GStatusBar.h>
#include <unistd.h>
#include <stdio.h>
-#include <errno.h>
#include "DirectoryView.h"
static GWindow* make_window();
@@ -33,13 +29,21 @@ GWindow* make_window()
auto* widget = new GWidget;
window->set_main_widget(widget);
+ widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
+
auto* directory_view = new DirectoryView(widget);
- directory_view->set_relative_rect({ 0, 0, 240, 300 });
+
+ auto* statusbar = new GStatusBar(widget);
+ statusbar->set_text("Welcome!");
directory_view->on_path_change = [window] (const String& new_path) {
window->set_title(String::format("FileManager: %s", new_path.characters()));
};
+ directory_view->on_status_message = [statusbar] (String message) {
+ statusbar->set_text(move(message));
+ };
+
directory_view->open("/");
return window;
diff --git a/Applications/FontEditor/Makefile b/Applications/FontEditor/Makefile
index eafdbb0266..dd592ab7c8 100644
--- a/Applications/FontEditor/Makefile
+++ b/Applications/FontEditor/Makefile
@@ -23,7 +23,7 @@ LDFLAGS = -static --strip-debug -melf_i386 -e _start --gc-sections
all: $(APP)
$(APP): $(OBJS)
- $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../LibGUI/LibGUI.a ../LibC/LibC.a
+ $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../../LibGUI/LibGUI.a ../../LibC/LibC.a
.cpp.o:
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
diff --git a/Applications/Launcher/Makefile b/Applications/Launcher/Makefile
index 05ee7ea0ba..cd6a918d08 100644
--- a/Applications/Launcher/Makefile
+++ b/Applications/Launcher/Makefile
@@ -22,7 +22,7 @@ LDFLAGS = -static --strip-debug -melf_i386 -e _start --gc-sections
all: $(APP)
$(APP): $(OBJS)
- $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../LibGUI/LibGUI.a ../LibC/LibC.a
+ $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../../LibGUI/LibGUI.a ../../LibC/LibC.a
.cpp.o:
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
diff --git a/Applications/Terminal/Makefile b/Applications/Terminal/Makefile
index bb7f277265..6f8dde1e3e 100644
--- a/Applications/Terminal/Makefile
+++ b/Applications/Terminal/Makefile
@@ -23,7 +23,7 @@ LDFLAGS = -static --strip-debug -melf_i386 -e _start --gc-sections
all: $(APP)
$(APP): $(OBJS)
- $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../LibC/LibC.a
+ $(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../../LibC/LibC.a
.cpp.o:
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<