pamac-classic/src/packages_chooser_dialog.vala

56 lines
1.8 KiB
Vala
Raw Normal View History

2014-10-22 13:44:02 -03:00
/*
* pamac-vala
*
* Copyright (C) 2014 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/manager/packages_chooser_dialog.ui")]
public class PackagesChooserDialog : Gtk.FileChooserDialog {
ManagerWindow window;
Transaction transaction;
public PackagesChooserDialog (ManagerWindow window, Transaction transaction) {
Object (transient_for: window, use_header_bar: 0);
Gtk.FileFilter package_filter = new Gtk.FileFilter ();
2014-11-01 13:59:16 -03:00
package_filter.set_filter_name (dgettext (null, "Alpm Package"));
2014-10-22 13:44:02 -03:00
package_filter.add_pattern ("*.pkg.tar.xz");
this.add_filter (package_filter);
this.window = window;
this.transaction = transaction;
}
[GtkCallback]
public void on_file_activated () {
SList<string> packages_paths = this.get_filenames ();
if (packages_paths.length () != 0) {
foreach (string path in packages_paths) {
2014-10-30 10:44:09 -03:00
transaction.to_load.insert (path, path);
2014-10-22 13:44:02 -03:00
}
window.get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.WATCH));
this.hide ();
while (Gtk.events_pending ())
Gtk.main_iteration ();
transaction.run ();
}
}
}
}