Graphical package manager for pacman based on pamac 5.x.x
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

installer.vala 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * pamac-vala
  3. *
  4. * Copyright (C) 2017 Chris Cromer <cromer@cromnix.org>
  5. * Copyright (C) 2014-2017 Guillaume Benoit <guillaume@manjaro.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a get of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. namespace Pamac {
  21. public class Installer: Gtk.Application {
  22. Transaction transaction;
  23. ProgressDialog progress_dialog;
  24. bool important_details;
  25. public Installer () {
  26. application_id = "org.pamac.installer";
  27. flags |= ApplicationFlags.HANDLES_OPEN;
  28. }
  29. public override void startup () {
  30. // i18n
  31. Intl.bindtextdomain(Constants.GETTEXT_PACKAGE, Path.build_filename(Constants.DATADIR,"locale"));
  32. Intl.setlocale (LocaleCategory.ALL, "");
  33. Intl.textdomain(Constants.GETTEXT_PACKAGE);
  34. Intl.bind_textdomain_codeset(Constants.GETTEXT_PACKAGE, "utf-8" );
  35. base.startup ();
  36. important_details = false;
  37. // integrate progress box and term widget
  38. progress_dialog = new ProgressDialog ();
  39. transaction = new Transaction (progress_dialog as Gtk.ApplicationWindow);
  40. transaction.mode = Transaction.Mode.INSTALLER;
  41. transaction.finished.connect (on_transaction_finished);
  42. transaction.important_details_outpout.connect (on_important_details_outpout);
  43. progress_dialog.box.pack_start (transaction.progress_box);
  44. progress_dialog.box.reorder_child (transaction.progress_box, 0);
  45. transaction.term_window.height_request = 200;
  46. progress_dialog.expander.add (transaction.term_window);
  47. progress_dialog.close_button.clicked.connect (on_close_button_clicked);
  48. progress_dialog.close_button.visible = false;
  49. this.hold ();
  50. }
  51. public override void activate () {
  52. this.release ();
  53. }
  54. public override void open (File[] files, string hint) {
  55. foreach (unowned File file in files) {
  56. transaction.to_load.add (file.get_path ());
  57. }
  58. progress_dialog.show ();
  59. if (transaction.get_lock ()) {
  60. transaction.run ();
  61. } else {
  62. Gtk.MessageDialog msg = new Gtk.MessageDialog (this as Gtk.ApplicationWindow, Gtk.DialogFlags.MODAL, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK, dgettext (null, "Unable to lock database!"));
  63. msg.response.connect ((response_id) => {
  64. msg.destroy();
  65. this.release ();
  66. });
  67. msg.show ();
  68. }
  69. }
  70. void on_important_details_outpout (bool must_show) {
  71. important_details = true;
  72. progress_dialog.expander.expanded = true;
  73. }
  74. void on_close_button_clicked () {
  75. this.release ();
  76. }
  77. void on_transaction_finished () {
  78. transaction.stop_daemon ();
  79. if (important_details) {
  80. progress_dialog.close_button.visible = true;
  81. } else {
  82. this.release ();
  83. }
  84. }
  85. public static int main (string[] args) {
  86. var installer = new Installer();
  87. return installer.run (args);
  88. }
  89. }
  90. }