Skip to content
This repository was archived by the owner on Apr 2, 2022. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ executable(
join_paths('src', 'Views', 'ErrorView.vala'),
join_paths('src', 'Views', 'WelcomeView.vala'),
join_paths('src', 'Widgets', 'BrowserButton.vala'),
join_paths('src', 'Widgets', 'DownloadsButton.vala'),
join_paths('src', 'Widgets', 'FindBar.vala'),
join_paths('src', 'Widgets', 'UrlEntry.vala'),
join_paths('src', 'Widgets', 'WebView.vala'),
Expand Down
4 changes: 4 additions & 0 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class Ephemeral.MainWindow : Gtk.Window {
private Gtk.Button stop_button;
private UrlEntry url_entry;
private BrowserButton browser_button;
private DownloadsButton downloads_button;
private Gtk.Button erase_button;
private uint overlay_timeout_id = 0;

Expand Down Expand Up @@ -108,6 +109,8 @@ public class Ephemeral.MainWindow : Gtk.Window {
browser_button = new BrowserButton (this, web_view);
browser_button.sensitive = false;

downloads_button = new DownloadsButton ();

var settings_button = new Gtk.MenuButton ();
settings_button.image = new Gtk.Image.from_icon_name ("open-menu", Application.instance.icon_size);
settings_button.tooltip_text = _("Menu");
Expand Down Expand Up @@ -273,6 +276,7 @@ public class Ephemeral.MainWindow : Gtk.Window {
header.pack_start (new Gtk.Separator (Gtk.Orientation.VERTICAL));
header.pack_end (settings_button);
header.pack_end (browser_button);
header.pack_end (downloads_button);
header.pack_end (erase_button);
header.pack_end (new Gtk.Separator (Gtk.Orientation.VERTICAL));

Expand Down
109 changes: 109 additions & 0 deletions src/Widgets/DownloadsButton.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Copyright © 2019 Cassidy James Blaede (https://cassidyjames.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Cassidy James Blaede <[email protected]>
*/

public class Ephemeral.DownloadsButton : Gtk.Revealer {
public DownloadsButton () {
Object ();
}

construct {
tooltip_text = _("Downloads");
tooltip_markup = Granite.markup_accel_tooltip (
{"<Ctrl>j"},
tooltip_text
);

// FIXME: Hide when no downloads
reveal_child = true;

var button = new Gtk.MenuButton ();
button.image = new Gtk.Image.from_icon_name ("folder-download", Application.instance.icon_size);

var popover = new Gtk.Popover (button);
button.popover = popover;

var popover_grid = new Gtk.Grid ();
popover_grid.margin_top = popover_grid.margin_bottom = 3;
popover_grid.orientation = Gtk.Orientation.VERTICAL;

// FIXME: Foreach download item…
string[] items = {"downloaded-image.jpg", "elementary-os-5.1-hera_20191014.iso"};

foreach (string item in items) {
// FIXME: Get an actual mimetype icon
var image = new Gtk.Image.from_icon_name ("application-x-partial-download", Gtk.IconSize.DND);

var label = new Gtk.Label (item);
label.hexpand = true;
label.xalign = 0;

var progressbar = new Gtk.ProgressBar ();
progressbar.fraction = 0.69f;
progressbar.get_style_context ().add_class ("osd");

var overlay = new Gtk.Overlay ();
overlay.add (label);
overlay.add_overlay (progressbar);

var open_grid = new Gtk.Grid ();
open_grid.add (image);
open_grid.add (overlay);

var open_button = new Gtk.Button ();
open_button.always_show_image = true;
open_button.expand = true;
open_button.tooltip_text = _("Open");
open_button.add (open_grid);

var folder_button = new Gtk.Button.from_icon_name ("folder-open", Gtk.IconSize.MENU);
folder_button.halign = Gtk.Align.END;
folder_button.margin_start = folder_button.margin_end = 6;
folder_button.tooltip_text = _("Open in folder");
folder_button.valign = Gtk.Align.CENTER;
folder_button.get_style_context ().add_class ("circular");

folder_button.clicked.connect (() => {
critical ("%s folder", item);
});

var open_button_context = open_button.get_style_context ();
open_button_context.add_class (Gtk.STYLE_CLASS_MENUITEM);
open_button_context.add_class (Gtk.STYLE_CLASS_FLAT);


open_button.clicked.connect (() => {
critical ("%s itself", item);
});

var item_grid = new Gtk.Grid ();
item_grid.add (open_button);
item_grid.add (folder_button);

popover_grid.add (item_grid);
}
// FIXME: END foreach

popover_grid.show_all ();
popover.add (popover_grid);

add (button);
}
}