Skip to content

Commit

Permalink
JobsView: GTK4 prep
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored and tintou committed Oct 18, 2023
1 parent c8ccfe9 commit bba653f
Showing 1 changed file with 33 additions and 35 deletions.
68 changes: 33 additions & 35 deletions src/Views/JobsView.vala
Original file line number Diff line number Diff line change
@@ -1,63 +1,56 @@
// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
/*-
* Copyright 2015 - 2022 elementary, Inc. (https://elementary.io)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
* Boston, MA 02110-1301, USA.
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2015-2023 elementary, Inc. (https://elementary.io)
*
* Authored by: Corentin Noël <[email protected]>
*/

public class Printers.JobsView : Gtk.Frame {
private Printer printer;
public Printer printer { get; construct; }

private Gtk.ListBox list_box;
private Gtk.Button clear_button;

public JobsView (Printer printer) {
this.printer = printer;
Object (printer: printer);
}

construct {
var alert = new Granite.Widgets.AlertView (_("Print Queue Is Empty"), _("There are no pending jobs in the queue."), "");
alert.show_all ();

list_box = new Gtk.ListBox ();
list_box.selection_mode = Gtk.SelectionMode.SINGLE;
list_box = new Gtk.ListBox () {
selection_mode = SINGLE
};
list_box.set_placeholder (alert);
list_box.set_header_func ((Gtk.ListBoxUpdateHeaderFunc) update_header);
list_box.set_sort_func ((Gtk.ListBoxSortFunc) compare);

var scrolled = new Gtk.ScrolledWindow (null, null);
scrolled.expand = true;
scrolled.add (list_box);
scrolled.show_all ();
var scrolled = new Gtk.ScrolledWindow (null, null) {
child = list_box,
hexpand = true,
vexpand = true
};

var clear_button_box = new Gtk.Box (HORIZONTAL, 0);
clear_button_box.add (new Gtk.Image.from_icon_name ("edit-clear-all-symbolic", BUTTON));
clear_button_box.add (new Gtk.Label (_("Clear All")));

clear_button = new Gtk.Button.with_label (_("Clear All")) {
always_show_image = true,
image = new Gtk.Image.from_icon_name ("edit-clear-all-symbolic", Gtk.IconSize.SMALL_TOOLBAR),
clear_button = new Gtk.Button () {
child = clear_button_box,
sensitive = list_box.get_children ().length () > 0
};
clear_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);

var actionbar = new Gtk.ActionBar ();
actionbar.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);
actionbar.add (clear_button);
actionbar.pack_start (clear_button);

var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
var box = new Gtk.Box (VERTICAL, 0);
box.add (scrolled);
box.add (actionbar);

add (box);
child = box;

refresh_job_list ();

Expand Down Expand Up @@ -107,10 +100,15 @@ public class Printers.JobsView : Gtk.Frame {
[CCode (instance_pos = -1)]
private void update_header (JobRow row1, JobRow? row2) {
if (!row1.job.is_ongoing && (row2 == null || row2.job.is_ongoing)) {
var label = new Gtk.Label (_("Completed Jobs"));
label.xalign = 0;
label.margin = 3;
var label = new Gtk.Label (_("Completed Jobs")) {
xalign = 0,
margin_top = 3,
margin_end = 3,
margin_bottom = 3,
margin_start = 3
};
label.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL);

row1.set_header (label);
} else {
row1.set_header (null);
Expand Down

0 comments on commit bba653f

Please sign in to comment.