add headerbars, improve dialogs and updater

This commit is contained in:
guinux
2016-04-23 17:27:01 +02:00
parent 0105b98f9e
commit 6046da7729
27 changed files with 633 additions and 705 deletions

View File

@@ -25,9 +25,9 @@ COMMON_SOURCES = common.vala \
TRANSACTION_SOURCES = package.vala \
transaction.vala \
history_dialog.vala \
choose_provider_dialog.vala \
transaction_sum_dialog.vala \
transaction_info_dialog.vala \
progress_dialog.vala
PREFERENCES_SOURCES = preferences_dialog.vala \
@@ -94,7 +94,7 @@ libpamac.so: $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(PREFERENCES_SOURCES) ../
$(TRANSACTION_SOURCES) \
$(PREFERENCES_SOURCES)
pamac-manager: libpamac.so choose_dep_dialog.vala history_dialog.vala transaction_info_dialog.vala ../resources/manager_resources.c manager_window.vala manager.vala
pamac-manager: libpamac.so choose_dep_dialog.vala ../resources/manager_resources.c manager_window.vala manager.vala
valac -o pamac-manager \
$(COMMON_VALA_FLAGS) \
$(PAMAC_LIB_FLAGS) \
@@ -104,7 +104,6 @@ pamac-manager: libpamac.so choose_dep_dialog.vala history_dialog.vala transactio
--gresources=$(MANAGER_GRESOURCE_FILE) \
../resources/manager_resources.c \
choose_dep_dialog.vala \
history_dialog.vala \
manager_window.vala \
manager.vala

View File

@@ -22,15 +22,13 @@ namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/manager/choose_dep_dialog.ui")]
class ChooseDependenciesDialog : Gtk.Dialog {
[GtkChild]
public Gtk.Label label;
[GtkChild]
public Gtk.TreeView treeview;
public Gtk.ListStore deps_list;
public ChooseDependenciesDialog (Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 0);
Object (transient_for: window, use_header_bar: 1);
deps_list = new Gtk.ListStore (2, typeof (bool), typeof (string));
treeview.set_model (deps_list);

View File

@@ -22,17 +22,14 @@ namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/preferences/choose_ignorepkgs_dialog.ui")]
class ChooseIgnorepkgsDialog : Gtk.Dialog {
[GtkChild]
public Gtk.Label label;
[GtkChild]
public Gtk.TreeView treeview;
public Gtk.ListStore pkgs_list;
public ChooseIgnorepkgsDialog (Gtk.Window window) {
Object (transient_for: window, use_header_bar: 0);
Object (transient_for: window, use_header_bar: 1);
label.set_markup ("<b>%s</b>".printf (dgettext (null, "Choose the packages you do not want to upgrade")));
pkgs_list = new Gtk.ListStore (2, typeof (bool), typeof (string));
treeview.set_model (pkgs_list);
}
@@ -40,10 +37,10 @@ namespace Pamac {
[GtkCallback]
void on_renderertoggle_toggled (string path) {
Gtk.TreeIter iter;
GLib.Value selected;
bool selected;
if (pkgs_list.get_iter_from_string (out iter, path)) {
pkgs_list.get_value (iter, 0, out selected);
pkgs_list.set_value (iter, 0, !((bool) selected));
pkgs_list.get (iter, 0, out selected);
pkgs_list.set (iter, 0, !selected);
}
}
}

View File

@@ -22,13 +22,8 @@ namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/choose_provider_dialog.ui")]
class ChooseProviderDialog : Gtk.Dialog {
[GtkChild]
public Gtk.Label label;
[GtkChild]
public Gtk.ComboBoxText comboboxtext;
public ChooseProviderDialog (Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 0);
Object (transient_for: window, use_header_bar: 1);
}
}
}

View File

@@ -19,14 +19,14 @@
namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/manager/history_dialog.ui")]
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/history_dialog.ui")]
class HistoryDialog : Gtk.Dialog {
[GtkChild]
public Gtk.TextView textview;
public HistoryDialog (ManagerWindow window) {
Object (transient_for: window, use_header_bar: 0);
public HistoryDialog (Gtk.ApplicationWindow window) {
Object (transient_for: window, use_header_bar: 1);
}
}
}

View File

@@ -17,8 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const string VERSION = "4.0.0";
namespace Pamac {
class ActivableCellRendererPixbuf : Gtk.CellRendererPixbuf {
@@ -61,6 +59,8 @@ namespace Pamac {
[GtkChild]
Gtk.Stack filters_stack;
[GtkChild]
Gtk.StackSwitcher filters_stackswitcher;
[GtkChild]
Gtk.SearchEntry search_entry;
[GtkChild]
Gtk.TreeView search_treeview;
@@ -101,9 +101,9 @@ namespace Pamac {
[GtkChild]
Gtk.Label transaction_infos_label;
[GtkChild]
Gtk.Button transaction_infos_apply_button;
Gtk.Button apply_button;
[GtkChild]
Gtk.Button transaction_infos_cancel_button;
Gtk.Button cancel_button;
// menu
Gtk.Menu right_click_menu;
@@ -300,6 +300,7 @@ namespace Pamac {
show_default_pkgs ();
search_entry.grab_focus ();
main_stack.notify["visible-child"].connect (on_main_stack_visible_child_changed);
filters_stack.notify["visible-child"].connect (on_filters_stack_visible_child_changed);
packages_stack.notify["visible-child"].connect (on_packages_stack_visible_child_changed);
@@ -965,16 +966,18 @@ namespace Pamac {
void choose_opt_dep (GLib.List<string> pkgnames) {
foreach (unowned string pkgname in pkgnames) {
var choose_dep_dialog = new ChooseDependenciesDialog (this);
int length = 0;
//~ int length = 0;
foreach (unowned string optdep in transaction.get_pkg_uninstalled_optdeps (pkgname)) {
length++;
//~ length++;
choose_dep_dialog.deps_list.insert_with_values (null, -1,
0, false,
1, optdep);
}
choose_dep_dialog.label.set_markup ("<b>%s</b>".printf (
ngettext ("%s has %u uninstalled optional dependency.\nChoose if you would like to install it",
"%s has %u uninstalled optional dependencies.\nChoose those you would like to install", length).printf (pkgname, length)));
choose_dep_dialog.title = dgettext (null, "Choose optional dependencies for %s").printf (pkgname);
//~ var headerbar = choose_dep_dialog.get_header_bar () as Gtk.HeaderBar;
//~ headerbar.subtitle = ngettext ("%s has %u uninstalled optional dependency",
//~ "%s has %u uninstalled optional dependencies",
//~ length).printf (pkgname, length);
if (choose_dep_dialog.run () == Gtk.ResponseType.OK) {
choose_dep_dialog.deps_list.foreach ((model, path, iter) => {
bool selected;
@@ -1390,44 +1393,30 @@ namespace Pamac {
}
}
void on_main_stack_visible_child_changed () {
switch (main_stack.visible_child_name) {
case "browse":
filters_stackswitcher.visible = true;
break;
case "details":
filters_stackswitcher.visible = false;
break;
default:
break;
}
}
void on_filters_stack_visible_child_changed () {
refresh_packages_list ();
}
[GtkCallback]
void on_history_item_activate () {
var file = GLib.File.new_for_path ("/var/log/pamac.log");
if (!file.query_exists ()) {
GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
} else {
StringBuilder text = new StringBuilder ();
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
var dis = new DataInputStream (file.read ());
string line;
// Read lines until end of file (null) is reached
while ((line = dis.read_line ()) != null) {
// construct text in reverse order
text.prepend (line + "\n");
}
} catch (GLib.Error e) {
GLib.stderr.printf ("%s\n", e.message);
}
var history_dialog = new HistoryDialog (this);
history_dialog.textview.buffer.set_text (text.str, (int) text.len);
history_dialog.show ();
history_dialog.response.connect (() => {
history_dialog.destroy ();
});
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
}
void on_history_button_clicked () {
transaction.run_history_dialog ();
}
[GtkCallback]
void on_local_item_activate () {
void on_local_button_clicked () {
Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog (
dgettext (null, "Install Local Packages"), this, Gtk.FileChooserAction.OPEN,
dgettext (null, "_Cancel"), Gtk.ResponseType.CANCEL,
@@ -1465,25 +1454,17 @@ namespace Pamac {
}
[GtkCallback]
void on_preferences_item_activate () {
void on_preferences_button_clicked () {
transaction.run_preferences_dialog.begin ();
}
[GtkCallback]
void on_about_item_activate () {
Gtk.show_about_dialog (
this,
"program_name", "Pamac",
"logo_icon_name", "system-software-install",
"comments", dgettext (null, "A Gtk3 frontend for libalpm"),
"copyright", "Copyright © 2016 Guillaume Benoit",
"version", VERSION,
"license_type", Gtk.License.GPL_3_0,
"website", "http://manjaro.org");
void on_about_button_clicked () {
transaction.run_about_dialog ();
}
[GtkCallback]
void on_transaction_infos_details_button_clicked () {
void on_details_button_clicked () {
if (transaction_running) {
transaction.show_progress ();
} else {
@@ -1500,14 +1481,13 @@ namespace Pamac {
}
[GtkCallback]
void on_transaction_infos_apply_button_clicked () {
//this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
void on_apply_button_clicked () {
transaction_running = true;
transaction.run ();
}
[GtkCallback]
void on_transaction_infos_cancel_button_clicked () {
void on_cancel_button_clicked () {
if (transaction_running) {
transaction.cancel ();
} else {
@@ -1518,17 +1498,17 @@ namespace Pamac {
}
[GtkCallback]
void on_refresh_item_activate () {
void on_refresh_button_clicked () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
refreshing = true;
transaction.start_refresh (false);
transaction_infos_apply_button.visible = false;
apply_button.visible = false;
transaction_infobox.visible = true;
}
void on_start_transaction () {
transaction_infos_cancel_button.visible = false;
transaction_infos_apply_button.visible = false;
cancel_button.visible = false;
apply_button.visible = false;
}
void on_emit_action (string action) {
@@ -1546,8 +1526,8 @@ namespace Pamac {
refreshing = false;
} else {
transaction_running = false;
transaction_infos_cancel_button.visible = true;
transaction_infos_apply_button.visible = true;
cancel_button.visible = true;
apply_button.visible = true;
}
set_pendings_operations ();
}

View File

@@ -62,7 +62,7 @@ namespace Pamac {
uint64 previous_refresh_period;
public PreferencesDialog (Transaction transaction) {
Object (transient_for: transaction.application_window, use_header_bar: 0);
Object (transient_for: transaction.application_window, use_header_bar: 1);
this.transaction = transaction;
refresh_period_label.set_markup (dgettext (null, "How often to check for updates, value in hours") +":");

View File

@@ -37,7 +37,7 @@ namespace Pamac {
Vte.Pty pty;
public ProgressDialog (Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 0);
Object (transient_for: window, use_header_bar: 1);
//creating terminal
term = new Vte.Terminal ();

View File

@@ -17,6 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const string VERSION = "4.0.0";
namespace Pamac {
[DBus (name = "org.manjaro.pamac")]
interface Daemon : Object {
@@ -141,10 +143,10 @@ namespace Pamac {
uint64 rates_nb;
Timer timer;
bool success;
StringBuilder dialog_textbuffer;
//dialogs
TransactionSumDialog transaction_sum_dialog;
TransactionInfoDialog transaction_info_dialog;
ProgressDialog progress_dialog;
//parent window
public Gtk.ApplicationWindow? application_window { get; private set; }
@@ -180,10 +182,8 @@ namespace Pamac {
//creating dialogs
this.application_window = application_window;
transaction_sum_dialog = new TransactionSumDialog (application_window);
transaction_info_dialog = new TransactionInfoDialog (application_window);
progress_dialog = new ProgressDialog (application_window);
progress_dialog.close_button.clicked.connect (hide_progress);
progress_dialog.delete_event.connect (progress_dialog.hide_on_delete);
progress_dialog.cancel_button.clicked.connect (on_progress_dialog_cancel_button_clicked);
// connect to child_exited signal which will only be emit after a call to watch_child
progress_dialog.term.child_exited.connect (on_term_child_exited);
@@ -193,6 +193,38 @@ namespace Pamac {
sysupgrade_after_trans = false;
timer = new Timer ();
success = false;
dialog_textbuffer = new StringBuilder ();
}
public void run_history_dialog () {
var file = GLib.File.new_for_path ("/var/log/pamac.log");
if (!file.query_exists ()) {
GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
} else {
StringBuilder text = new StringBuilder ();
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
var dis = new DataInputStream (file.read ());
string line;
// Read lines until end of file (null) is reached
while ((line = dis.read_line ()) != null) {
// construct text in reverse order
text.prepend (line + "\n");
}
} catch (GLib.Error e) {
GLib.stderr.printf ("%s\n", e.message);
}
var history_dialog = new HistoryDialog (application_window);
history_dialog.textview.buffer.set_text (text.str, (int) text.len);
history_dialog.show ();
history_dialog.response.connect (() => {
history_dialog.destroy ();
});
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
}
}
public async void run_preferences_dialog () {
@@ -213,6 +245,18 @@ namespace Pamac {
daemon.disconnect (handler_id);
}
public void run_about_dialog () {
Gtk.show_about_dialog (
application_window,
"program_name", "Pamac",
"logo_icon_name", "system-software-install",
"comments", dgettext (null, "A Gtk3 frontend for libalpm"),
"copyright", "Copyright © 2016 Guillaume Benoit",
"version", VERSION,
"license_type", Gtk.License.GPL_3_0,
"website", "http://manjaro.org");
}
public ErrorInfos get_current_error () {
try {
return daemon.get_current_error ();
@@ -304,12 +348,6 @@ namespace Pamac {
string action = dgettext (null, "Synchronizing package databases") + "...";
reset_progress_dialog (action);
emit_action (action);
if (mode != Mode.MANAGER) {
progress_dialog.show ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
}
try {
daemon.refresh_finished.connect (on_refresh_finished);
daemon.start_refresh (force);
@@ -637,12 +675,6 @@ namespace Pamac {
success = false;
}
if (success) {
if (mode != Mode.MANAGER) {
progress_dialog.show ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
}
try {
daemon.start_trans_prepare ();
} catch (IOError e) {
@@ -718,12 +750,6 @@ namespace Pamac {
string action = dgettext (null, "Preparing") + "...";
reset_progress_dialog (action);
emit_action (action);
if (mode != Mode.MANAGER) {
progress_dialog.show ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
}
// run
if (to_install.length == 0
&& to_remove.length == 0
@@ -791,16 +817,36 @@ namespace Pamac {
void choose_provider (string depend, string[] providers) {
var choose_provider_dialog = new ChooseProviderDialog (application_window);
choose_provider_dialog.label.set_markup ("<b>%s</b>".printf (dgettext (null, "Choose a provider for %s").printf (depend)));
choose_provider_dialog.title = dgettext (null, "Choose a provider for %s").printf (depend);
unowned Gtk.Box box = choose_provider_dialog.get_content_area ();
Gtk.RadioButton? last_radiobutton = null;
Gtk.RadioButton? first_radiobutton = null;
foreach (unowned string provider in providers) {
choose_provider_dialog.comboboxtext.append_text (provider);
var radiobutton = new Gtk.RadioButton.with_label_from_widget (last_radiobutton, provider);
radiobutton.visible = true;
// active first provider
if (last_radiobutton == null) {
radiobutton.active = true;
first_radiobutton = radiobutton;
}
last_radiobutton = radiobutton;
box.add (radiobutton);
}
choose_provider_dialog.comboboxtext.active = 0;
choose_provider_dialog.run ();
try {
daemon.choose_provider (choose_provider_dialog.comboboxtext.active);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
// get active provider
int index = 0;
// list is given in reverse order so reverse it !
SList<unowned Gtk.RadioButton> list = last_radiobutton.get_group ().copy ();
list.reverse ();
foreach (var radiobutton in list) {
if (radiobutton.active) {
try {
daemon.choose_provider (index);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
}
index++;
}
choose_provider_dialog.destroy ();
while (Gtk.events_pending ()) {
@@ -814,7 +860,6 @@ namespace Pamac {
uint64 dsize = 0;
transaction_summary.remove_all ();
var summary = TransactionSummary ();
transaction_sum_dialog.top_label.set_markup ("<big><b>%s</b></big>".printf (dgettext (null, "Transaction Summary")));
transaction_sum_dialog.sum_list.clear ();
try {
summary = daemon.get_transaction_summary ();
@@ -908,10 +953,10 @@ namespace Pamac {
}
}
if (dsize == 0) {
transaction_sum_dialog.bottom_label.visible = false;
transaction_sum_dialog.top_label.visible = false;
} else {
transaction_sum_dialog.bottom_label.set_markup ("<b>%s: %s</b>".printf (dgettext (null, "Total download size"), format_size (dsize)));
transaction_sum_dialog.bottom_label.visible = true;
transaction_sum_dialog.top_label.set_markup ("<b>%s: %s</b>".printf (dgettext (null, "Total download size"), format_size (dsize)));
transaction_sum_dialog.top_label.visible = true;
}
return type;
}
@@ -970,11 +1015,7 @@ namespace Pamac {
progress_dialog.hide ();
progress_dialog.spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
progress_dialog.expander.expanded = false;
Gtk.TextIter start_iter;
Gtk.TextIter end_iter;
transaction_info_dialog.textbuffer.get_start_iter (out start_iter);
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
dialog_textbuffer = new StringBuilder ();
}
public void release () {
@@ -1097,10 +1138,7 @@ namespace Pamac {
break;
case 33: //Alpm.Event.Type.OPTDEP_REMOVAL
detailed_action = dgettext (null, "%s optionally requires %s").printf (details[0], details[1]);
Gtk.TextIter end_iter;
string msg = detailed_action + "\n";
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
transaction_info_dialog.textbuffer.insert (ref end_iter, msg, msg.length);
dialog_textbuffer.append (detailed_action + "\n");
break;
case 34: //Alpm.Event.Type.DATABASE_MISSING
detailed_action = dgettext (null, "Database file for %s does not exist").printf (details[0]);
@@ -1312,7 +1350,6 @@ namespace Pamac {
void on_emit_log (uint level, string msg) {
// msg ends with \n
string? line = null;
Gtk.TextIter end_iter;
if (level == 1) { //Alpm.LogLevel.ERROR
if (previous_filename != "") {
line = dgettext (null, "Error") + ": " + previous_filename + ": " + msg;
@@ -1327,65 +1364,60 @@ namespace Pamac {
} else {
line = dgettext (null, "Warning") + ": " + msg;
}
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
transaction_info_dialog.textbuffer.insert (ref end_iter, msg, msg.length);
dialog_textbuffer.append (msg);
}
}
if (line != null) {
display_error (line, {});
progress_dialog.spawn_in_term ({"echo", "-n", line});
}
}
void show_warnings () {
if (transaction_info_dialog.textbuffer.text != "") {
transaction_info_dialog.title = dgettext (null, "Warning");
transaction_info_dialog.label.visible = false;
transaction_info_dialog.expander.visible = true;
transaction_info_dialog.expander.expanded = true;
transaction_info_dialog.run ();
transaction_info_dialog.hide ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
Gtk.TextIter start_iter;
Gtk.TextIter end_iter;
transaction_info_dialog.textbuffer.get_start_iter (out start_iter);
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
if (dialog_textbuffer.len > 0) {
var dialog = new Gtk.Dialog.with_buttons (dgettext (null, "Warning"),
application_window,
Gtk.DialogFlags.MODAL | Gtk.DialogFlags.USE_HEADER_BAR);
dialog.deletable = false;
unowned Gtk.Widget widget = dialog.add_button (dgettext (null, "_Close"), Gtk.ResponseType.CLOSE);
widget.can_focus = true;
widget.has_focus = true;
widget.can_default = true;
widget.has_default = true;
var scrolledwindow = new Gtk.ScrolledWindow (null, null);
var label = new Gtk.Label (dialog_textbuffer.str);
label.margin = 12;
scrolledwindow.visible = true;
label.visible = true;
scrolledwindow.add (label);
scrolledwindow.expand = true;
unowned Gtk.Box box = dialog.get_content_area ();
box.add (scrolledwindow);
dialog.default_width = 600;
dialog.default_height = 300;
dialog.run ();
dialog.destroy ();
dialog_textbuffer = new StringBuilder ();
}
}
void display_error (string message, string[] details) {
progress_dialog.spawn_in_term ({"echo", "-n", message});
Gtk.TextIter start_iter;
Gtk.TextIter end_iter;
transaction_info_dialog.title = dgettext (null, "Error");
transaction_info_dialog.label.visible = true;
transaction_info_dialog.label.label = message;
var dialog = new Gtk.MessageDialog (application_window,
Gtk.DialogFlags.MODAL,
Gtk.MessageType.ERROR,
Gtk.ButtonsType.CLOSE,
message);
if (details.length != 0) {
transaction_info_dialog.textbuffer.get_start_iter (out start_iter);
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
transaction_info_dialog.expander.visible = true;
transaction_info_dialog.expander.expanded = true;
var textbuffer = new StringBuilder ();
progress_dialog.spawn_in_term ({"echo", ":"});
foreach (unowned string detail in details) {
progress_dialog.spawn_in_term ({"echo", detail});
string str = detail + "\n";
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
transaction_info_dialog.textbuffer.insert (ref end_iter, str, str.length);
textbuffer.append (detail + "\n");
}
} else {
transaction_info_dialog.expander.visible = false;
}
transaction_info_dialog.run ();
transaction_info_dialog.hide ();
transaction_info_dialog.textbuffer.get_start_iter (out start_iter);
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
dialog.secondary_text = textbuffer.str;
}
dialog.run ();
dialog.destroy ();
}
void handle_error (ErrorInfos error) {

View File

@@ -1,40 +0,0 @@
/*
* pamac-vala
*
* Copyright (C) 2014-2016 Guillaume Benoit <guillaume@manjaro.org>
*
* 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 3 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 get of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/transaction_info_dialog.ui")]
class TransactionInfoDialog : Gtk.Dialog {
[GtkChild]
public Gtk.Label label;
[GtkChild]
public Gtk.Expander expander;
[GtkChild]
Gtk.TextView textview;
public Gtk.TextBuffer textbuffer;
public TransactionInfoDialog (Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 0);
textbuffer = textview.get_buffer ();
}
}
}

View File

@@ -25,14 +25,12 @@ namespace Pamac {
[GtkChild]
public Gtk.Label top_label;
[GtkChild]
public Gtk.Label bottom_label;
[GtkChild]
Gtk.TreeView treeview;
public Gtk.ListStore sum_list;
public TransactionSumDialog (Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 0);
Object (transient_for: window, use_header_bar: 1);
sum_list = new Gtk.ListStore (4, typeof (string), typeof (string), typeof (string), typeof (string));
treeview.set_model (sum_list);

View File

@@ -23,7 +23,7 @@ namespace Pamac {
class UpdaterWindow : Gtk.ApplicationWindow {
[GtkChild]
Gtk.Label top_label;
Gtk.HeaderBar headerbar;
[GtkChild]
Gtk.StackSwitcher stackswitcher;
[GtkChild]
@@ -41,7 +41,15 @@ namespace Pamac {
[GtkChild]
Gtk.Label bottom_label;
[GtkChild]
Gtk.Box transaction_infobox;
[GtkChild]
Gtk.Label transaction_infos_label;
[GtkChild]
Gtk.Button details_button;
[GtkChild]
Gtk.Button apply_button;
[GtkChild]
Gtk.Button cancel_button;
Gtk.ListStore repos_updates_list;
Gtk.ListStore aur_updates_list;
@@ -52,7 +60,10 @@ namespace Pamac {
Object (application: application);
bottom_label.visible = false;
apply_button.sensitive = false;
apply_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
details_button.visible = false;
cancel_button.visible = false;
transaction_infobox.visible = false;
stackswitcher.visible = false;
aur_scrolledwindow.visible = false;
@@ -69,6 +80,8 @@ namespace Pamac {
transaction = new Transaction (this as Gtk.ApplicationWindow);
transaction.mode = Mode.UPDATER;
transaction.start_transaction.connect (on_start_transaction);
transaction.emit_action.connect (on_emit_action);
transaction.finished.connect (populate_updates_list);
transaction.get_updates_finished.connect (on_get_updates_finished);
@@ -77,23 +90,23 @@ namespace Pamac {
return false;
}
void set_apply_button_sensitive () {
bool sensitive = false;
void set_transaction_infobox_visible () {
bool visible = false;
repos_updates_list.foreach ((model, path, iter) => {
bool selected;
repos_updates_list.get (iter, 0, out selected);
sensitive = selected;
return sensitive;
visible = selected;
return visible;
});
if (!sensitive) {
if (!visible) {
aur_updates_list.foreach ((model, path, iter) => {
bool selected;
aur_updates_list.get (iter, 0, out selected);
sensitive = selected;
return sensitive;
visible = selected;
return visible;
});
}
apply_button.sensitive = sensitive;
transaction_infobox.visible = visible;
}
[GtkCallback]
@@ -110,7 +123,7 @@ namespace Pamac {
repos_updates_list.set (iter, 0, true);
transaction.temporary_ignorepkgs.remove (pkgname);
}
set_apply_button_sensitive ();
set_transaction_infobox_visible ();
}
[GtkCallback]
@@ -127,7 +140,7 @@ namespace Pamac {
aur_updates_list.set (iter, 0, true);
transaction.temporary_ignorepkgs.remove (pkgname);
}
set_apply_button_sensitive ();
set_transaction_infobox_visible ();
}
[GtkCallback]
@@ -139,8 +152,9 @@ namespace Pamac {
[GtkCallback]
void on_apply_button_clicked () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
transaction.sysupgrade (false);
details_button.visible = true;
cancel_button.visible = true;
}
[GtkCallback]
@@ -150,17 +164,46 @@ namespace Pamac {
}
[GtkCallback]
void on_close_button_clicked () {
this.application.quit ();
void on_history_button_clicked () {
transaction.run_history_dialog ();
}
[GtkCallback]
void on_about_button_clicked () {
transaction.run_about_dialog ();
}
[GtkCallback]
void on_details_button_clicked () {
transaction.show_progress ();
}
[GtkCallback]
void on_cancel_button_clicked () {
transaction.cancel ();
}
void on_start_transaction () {
cancel_button.visible = false;
apply_button.visible = false;
}
void on_emit_action (string action) {
transaction_infos_label.label = action;
}
void populate_updates_list () {
apply_button.visible = true;
apply_button.grab_default ();
details_button.visible = false;
cancel_button.visible = false;
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
transaction_infos_label.label = "";
transaction.start_get_updates ();
}
void on_get_updates_finished (Updates updates) {
top_label.set_markup ("");
headerbar.title = "";
repos_updates_list.clear ();
stackswitcher.visible = false;
repos_scrolledwindow.visible = true;
@@ -192,11 +235,11 @@ namespace Pamac {
}
uint updates_nb = repos_updates_nb + aur_updates_nb;
if (updates_nb == 0) {
top_label.set_markup("<b>%s</b>".printf (dgettext (null, "Your system is up-to-date")));
headerbar.title = dgettext (null, "Your system is up-to-date");
} else {
top_label.set_markup("<b>%s</b>".printf (dngettext (null, "%u available update", "%u available updates", updates_nb).printf (updates_nb)));
headerbar.title = dngettext (null, "%u available update", "%u available updates", updates_nb).printf (updates_nb);
}
set_apply_button_sensitive ();
set_transaction_infobox_visible ();
if (dsize != 0) {
bottom_label.set_markup("<b>%s: %s</b>".printf (dgettext (null, "Total download size"), format_size(dsize)));
bottom_label.visible = true;