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.

77 lines
2.2KB

  1. /*
  2. * pamac-vala
  3. *
  4. * Copyright (C) 2014-2016 Guillaume Benoit <guillaume@manjaro.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a get of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. namespace Pamac {
  20. [GtkTemplate (ui = "/org/manjaro/pamac/transaction/progress_dialog.ui")]
  21. class ProgressDialog : Gtk.Dialog {
  22. [GtkChild]
  23. public Gtk.ProgressBar progressbar;
  24. [GtkChild]
  25. public Gtk.Label action_label;
  26. [GtkChild]
  27. public Gtk.Button cancel_button;
  28. [GtkChild]
  29. public Gtk.Button close_button;
  30. [GtkChild]
  31. public Gtk.Expander expander;
  32. public Vte.Terminal term;
  33. Vte.Pty pty;
  34. public ProgressDialog (Gtk.ApplicationWindow? window) {
  35. Object (transient_for: window, use_header_bar: 0);
  36. //creating terminal
  37. term = new Vte.Terminal ();
  38. term.scroll_on_output = false;
  39. term.expand = true;
  40. term.height_request = 200;
  41. term.visible = true;
  42. // creating pty for term
  43. try {
  44. pty = term.pty_new_sync (Vte.PtyFlags.NO_HELPER);
  45. } catch (Error e) {
  46. stderr.printf ("Error: %s\n", e.message);
  47. }
  48. // add term in a grid with a scrollbar
  49. var grid = new Gtk.Grid ();
  50. grid.expand = true;
  51. grid.visible = true;
  52. var sb = new Gtk.Scrollbar (Gtk.Orientation.VERTICAL, term.vadjustment);
  53. sb.visible = true;
  54. grid.attach (term, 0, 0, 1, 1);
  55. grid.attach (sb, 1, 0, 1, 1);
  56. this.expander.add (grid);
  57. }
  58. public void spawn_in_term (string[] args, out Pid child_pid = null) {
  59. Pid intern_pid;
  60. try {
  61. Process.spawn_async (null, args, null, SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD, pty.child_setup, out intern_pid);
  62. } catch (SpawnError e) {
  63. stderr.printf ("SpawnError: %s\n", e.message);
  64. }
  65. child_pid = intern_pid;
  66. term.set_pty (pty);
  67. }
  68. }
  69. }