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.

manager_window.vala 77KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241
  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 2 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. //using GIO
  21. const string VERSION = Constants.VERSION;
  22. namespace Pamac {
  23. class ActivableCellRendererPixbuf : Gtk.CellRendererPixbuf {
  24. public signal void activated (Gtk.TreePath path);
  25. public ActivableCellRendererPixbuf () {
  26. Object ();
  27. this.mode = Gtk.CellRendererMode.ACTIVATABLE;
  28. }
  29. public override bool activate (Gdk.Event event, Gtk.Widget widget, string path, Gdk.Rectangle background_area,
  30. Gdk.Rectangle cell_area, Gtk.CellRendererState flags) {
  31. activated (new Gtk.TreePath.from_string (path));
  32. return true;
  33. }
  34. }
  35. [GtkTemplate (ui = "/org/pamac/manager/interface/manager_window.ui")]
  36. class ManagerWindow : Gtk.ApplicationWindow {
  37. // icons
  38. Gdk.Pixbuf? installed_icon;
  39. Gdk.Pixbuf? uninstalled_icon;
  40. Gdk.Pixbuf? to_install_icon;
  41. Gdk.Pixbuf? to_reinstall_icon;
  42. Gdk.Pixbuf? to_remove_icon;
  43. Gdk.Pixbuf? to_upgrade_icon;
  44. Gdk.Pixbuf? installed_locked_icon;
  45. Gdk.Pixbuf? available_locked_icon;
  46. // manager objects
  47. [GtkChild]
  48. public Gtk.Stack main_stack;
  49. [GtkChild]
  50. Gtk.Button button_back;
  51. [GtkChild]
  52. Gtk.MenuButton button_menu;
  53. #if ENABLE_HAMBURGER
  54. [GtkChild]
  55. Gtk.ModelButton preferences_button;
  56. #else
  57. [GtkChild]
  58. Gtk.HeaderBar headerbar;
  59. #endif
  60. [GtkChild]
  61. Gtk.TreeView packages_treeview;
  62. [GtkChild]
  63. Gtk.TreeViewColumn packages_state_column;
  64. #if DISABLE_AUR
  65. [GtkChild]
  66. Gtk.ScrolledWindow aur_scrolledwindow;
  67. #else
  68. [GtkChild]
  69. Gtk.TreeView aur_treeview;
  70. [GtkChild]
  71. Gtk.TreeViewColumn aur_state_column;
  72. #endif
  73. [GtkChild]
  74. public Gtk.Stack filters_stack;
  75. [GtkChild]
  76. Gtk.StackSwitcher filters_stackswitcher;
  77. [GtkChild]
  78. Gtk.SearchEntry search_entry;
  79. [GtkChild]
  80. Gtk.TreeView search_treeview;
  81. [GtkChild]
  82. Gtk.TreeView groups_treeview;
  83. [GtkChild]
  84. Gtk.TreeView states_treeview;
  85. [GtkChild]
  86. Gtk.TreeView repos_treeview;
  87. [GtkChild]
  88. Gtk.Stack packages_stack;
  89. [GtkChild]
  90. Gtk.StackSwitcher packages_stackswitcher;
  91. [GtkChild]
  92. Gtk.Label updated_label;
  93. [GtkChild]
  94. Gtk.Stack properties_stack;
  95. #if DISABLE_AUR
  96. #else
  97. [GtkChild]
  98. Gtk.StackSwitcher properties_stackswitcher;
  99. #endif
  100. [GtkChild]
  101. Gtk.Grid deps_grid;
  102. [GtkChild]
  103. Gtk.Grid details_grid;
  104. [GtkChild]
  105. Gtk.ScrolledWindow files_scrolledwindow;
  106. [GtkChild]
  107. Gtk.Label name_label;
  108. [GtkChild]
  109. Gtk.Label desc_label;
  110. [GtkChild]
  111. Gtk.Label link_label;
  112. [GtkChild]
  113. Gtk.Label licenses_label;
  114. [GtkChild]
  115. Gtk.ToggleButton remove_togglebutton;
  116. [GtkChild]
  117. Gtk.ToggleButton reinstall_togglebutton;
  118. [GtkChild]
  119. Gtk.ToggleButton install_togglebutton;
  120. [GtkChild]
  121. Gtk.TextView files_textview;
  122. [GtkChild]
  123. Gtk.Box transaction_infobox;
  124. [GtkChild]
  125. Gtk.Button details_button;
  126. [GtkChild]
  127. Gtk.Button apply_button;
  128. [GtkChild]
  129. Gtk.Button cancel_button;
  130. // menu
  131. Gtk.Menu right_click_menu;
  132. Gtk.MenuItem deselect_item;
  133. Gtk.MenuItem upgrade_item;
  134. Gtk.MenuItem install_item;
  135. Gtk.MenuItem remove_item;
  136. Gtk.MenuItem details_item;
  137. GLib.List<string> selected_pkgs;
  138. #if DISABLE_AUR
  139. #else
  140. GLib.List<string> selected_aur;
  141. #endif
  142. // liststores
  143. Gtk.ListStore search_list;
  144. Gtk.ListStore groups_list;
  145. Gtk.ListStore states_list;
  146. Gtk.ListStore repos_list;
  147. Gtk.ListStore packages_list;
  148. #if DISABLE_AUR
  149. #else
  150. Gtk.ListStore aur_list;
  151. #endif
  152. public Queue<string> display_package_queue;
  153. string current_package_displayed;
  154. public Transaction transaction;
  155. delegate void TransactionAction ();
  156. bool refreshing;
  157. bool important_details;
  158. bool transaction_running;
  159. bool sysupgrade_running;
  160. bool generate_mirrors_list;
  161. bool waiting;
  162. bool force_refresh;
  163. uint search_entry_timeout_id;
  164. public ManagerWindow (Gtk.Application application) {
  165. Object (application: application, title: "Pamac");
  166. #if ENABLE_HAMBURGER
  167. button_menu.toggled.connect (on_menu_button_toggled);
  168. #else
  169. headerbar.remove(button_menu);
  170. // connect the menu
  171. var action = new SimpleAction ("refreshdb", null);
  172. action.activate.connect (on_refresh_button_clicked);
  173. this.add_action (action);
  174. action = new SimpleAction ("viewhistory", null);
  175. action.activate.connect (on_history_button_clicked);
  176. this.add_action (action);
  177. action = new SimpleAction ("installlocal", null);
  178. action.activate.connect (on_local_button_clicked);
  179. this.add_action (action);
  180. action = new SimpleAction ("preferences", null);
  181. action.activate.connect (on_preferences_button_clicked);
  182. this.add_action (action);
  183. action = new SimpleAction ("about", null);
  184. action.activate.connect (on_about_button_clicked);
  185. this.add_action (action);
  186. #endif
  187. #if DISABLE_AUR
  188. packages_stack.remove (aur_scrolledwindow);
  189. packages_stackswitcher.visible = false;
  190. #else
  191. support_aur (false);
  192. aur_treeview.row_activated.connect (on_aur_treeview_row_activated);
  193. aur_treeview.button_press_event.connect (on_aur_treeview_button_press_event);
  194. aur_treeview.query_tooltip.connect (on_aur_treeview_query_tooltip);
  195. #endif
  196. button_back.visible = false;
  197. transaction_infobox.visible = false;
  198. refreshing = false;
  199. important_details = false;
  200. transaction_running = false;
  201. sysupgrade_running = false;
  202. generate_mirrors_list = false;
  203. this.title = dgettext (null, "Package Manager");
  204. updated_label.set_markup ("<b>%s</b>".printf (dgettext (null, "Your system is up-to-date")));
  205. while (Gtk.events_pending ()) {
  206. Gtk.main_iteration ();
  207. }
  208. right_click_menu = new Gtk.Menu ();
  209. deselect_item = new Gtk.MenuItem.with_label (dgettext (null, "Deselect"));
  210. deselect_item.activate.connect (on_deselect_item_activate);
  211. right_click_menu.append (deselect_item);
  212. upgrade_item = new Gtk.MenuItem.with_label (dgettext (null, "Upgrade"));
  213. upgrade_item.activate.connect (on_upgrade_item_activate);
  214. right_click_menu.append (upgrade_item);
  215. install_item = new Gtk.MenuItem.with_label (dgettext (null, "Install"));
  216. install_item.activate.connect (on_install_item_activate);
  217. right_click_menu.append (install_item);
  218. remove_item = new Gtk.MenuItem.with_label (dgettext (null, "Remove"));
  219. remove_item.activate.connect (on_remove_item_activate);
  220. right_click_menu.append (remove_item);
  221. var separator_item = new Gtk.SeparatorMenuItem ();
  222. right_click_menu.append (separator_item);
  223. details_item = new Gtk.MenuItem.with_label (dgettext (null, "Details"));
  224. details_item.activate.connect (on_details_item_activate);
  225. right_click_menu.append (details_item);
  226. right_click_menu.show_all ();
  227. search_list = new Gtk.ListStore (1, typeof (string));
  228. search_treeview.set_model (search_list);
  229. groups_list = new Gtk.ListStore (1, typeof (string));
  230. groups_treeview.set_model (groups_list);
  231. states_list = new Gtk.ListStore (1, typeof (string));
  232. states_treeview.set_model (states_list);
  233. repos_list = new Gtk.ListStore (1, typeof (string));
  234. repos_treeview.set_model (repos_list);
  235. packages_list = new Gtk.ListStore (7,
  236. typeof (uint), //origin
  237. typeof (string), //name
  238. typeof (string), //name+desc
  239. typeof (string), //version
  240. typeof (string), //repo
  241. typeof (uint64), //isize
  242. typeof (string)); //GLib.format (isize)
  243. packages_treeview.set_model (packages_list);
  244. // add custom cellrenderer to packages_treeview and aur_treewiew
  245. var packages_state_renderer = new ActivableCellRendererPixbuf ();
  246. packages_state_column.pack_start (packages_state_renderer, false);
  247. packages_state_column.set_cell_data_func (packages_state_renderer, (celllayout, cellrenderer, treemodel, treeiter) => {
  248. Gdk.Pixbuf pixbuf;
  249. uint origin;
  250. string pkgname;
  251. treemodel.get (treeiter, 0, out origin, 1, out pkgname);
  252. if (origin == 2) { //origin == Alpm.Package.From.LOCALDB
  253. if (unlikely (transaction.transaction_summary.contains (pkgname))) {
  254. pixbuf = installed_locked_icon;
  255. } else if (unlikely (transaction.should_hold (pkgname))) {
  256. pixbuf = installed_locked_icon;
  257. } else if (unlikely (transaction.to_install.contains (pkgname))) {
  258. pixbuf = to_reinstall_icon;
  259. } else if (unlikely (transaction.to_remove.contains (pkgname))) {
  260. pixbuf = to_remove_icon;
  261. } else {
  262. pixbuf = installed_icon;
  263. }
  264. } else if (unlikely (transaction.transaction_summary.contains (pkgname))) {
  265. pixbuf = available_locked_icon;
  266. } else if (unlikely (transaction.to_install.contains (pkgname))) {
  267. pixbuf = to_install_icon;
  268. } else if (unlikely (transaction.to_update.contains (pkgname))) {
  269. pixbuf = to_upgrade_icon;
  270. } else {
  271. pixbuf = uninstalled_icon;
  272. }
  273. cellrenderer.set ("pixbuf", pixbuf);
  274. });
  275. packages_state_renderer.activated.connect (on_packages_state_icon_activated);
  276. #if DISABLE_AUR
  277. #else
  278. aur_list = new Gtk.ListStore (6,
  279. typeof (uint), //origin
  280. typeof (string), //name
  281. typeof (string), //name+desc
  282. typeof (string), //version
  283. typeof (double), //popularity
  284. typeof (string)); //populariy to string
  285. // sort packages by popularity by default
  286. aur_list.set_sort_column_id (4, Gtk.SortType.DESCENDING);
  287. aur_treeview.set_model (aur_list);
  288. // add custom cellrenderer to aur_treewiew
  289. var aur_state_renderer = new ActivableCellRendererPixbuf ();
  290. aur_state_column.pack_start (aur_state_renderer, false);
  291. aur_state_column.set_cell_data_func (aur_state_renderer, (celllayout, cellrenderer, treemodel, treeiter) => {
  292. Gdk.Pixbuf pixbuf;
  293. uint origin;
  294. string pkgname;
  295. treemodel.get (treeiter, 0, out origin, 1, out pkgname);
  296. if (filters_stack.visible_child_name == "updates") {
  297. if (unlikely (transaction.temporary_ignorepkgs.contains (pkgname))) {
  298. pixbuf = uninstalled_icon;
  299. } else {
  300. pixbuf = to_upgrade_icon;
  301. }
  302. } else if ((uint) origin == 2) { //origin == Alpm.Package.From.LOCALDB
  303. if (unlikely (transaction.transaction_summary.contains (pkgname))) {
  304. pixbuf = installed_locked_icon;
  305. } else if (unlikely (transaction.should_hold (pkgname))) {
  306. pixbuf = installed_locked_icon;
  307. } else if (unlikely (transaction.to_install.contains (pkgname))) {
  308. pixbuf = to_reinstall_icon;
  309. } else if (unlikely (transaction.to_remove.contains (pkgname))) {
  310. pixbuf = to_remove_icon;
  311. } else {
  312. pixbuf = installed_icon;
  313. }
  314. } else if (unlikely (transaction.to_build.contains (pkgname))) {
  315. pixbuf = to_install_icon;
  316. } else {
  317. pixbuf = uninstalled_icon;
  318. }
  319. cellrenderer.set ("pixbuf", pixbuf);
  320. });
  321. aur_state_renderer.activated.connect (on_aur_state_icon_activated);
  322. #endif
  323. try {
  324. installed_icon = new Gdk.Pixbuf.from_resource ("/org/pamac/manager/pixmaps/package-installed-updated.png");
  325. uninstalled_icon = new Gdk.Pixbuf.from_resource ("/org/pamac/manager/pixmaps/package-available.png");
  326. to_install_icon = new Gdk.Pixbuf.from_resource ("/org/pamac/manager/pixmaps/package-install.png");
  327. to_reinstall_icon = new Gdk.Pixbuf.from_resource ("/org/pamac/manager/pixmaps/package-reinstall.png");
  328. to_remove_icon = new Gdk.Pixbuf.from_resource ("/org/pamac/manager/pixmaps/package-remove.png");
  329. to_upgrade_icon = new Gdk.Pixbuf.from_resource ("/org/pamac/manager/pixmaps/package-upgrade.png");
  330. installed_locked_icon = new Gdk.Pixbuf.from_resource ("/org/pamac/manager/pixmaps/package-installed-locked.png");
  331. available_locked_icon = new Gdk.Pixbuf.from_resource ("/org/pamac/manager/pixmaps/package-available-locked.png");
  332. } catch (GLib.Error e) {
  333. stderr.printf (e.message);
  334. }
  335. transaction = new Transaction (this as Gtk.ApplicationWindow);
  336. transaction.start_downloading.connect (on_start_downloading);
  337. transaction.stop_downloading.connect (on_stop_downloading);
  338. #if DISABLE_AUR
  339. #else
  340. transaction.start_building.connect (on_start_building);
  341. transaction.stop_building.connect (on_stop_building);
  342. #endif
  343. transaction.important_details_outpout.connect (on_important_details_outpout);
  344. transaction.finished.connect (on_transaction_finished);
  345. #if DISABLE_AUR
  346. #else
  347. transaction.save_pamac_config_finished.connect (on_save_pamac_config_finished);
  348. #endif
  349. transaction.set_pkgreason_finished.connect (on_set_pkgreason_finished);
  350. transaction.generate_mirrors_list.connect (on_generate_mirrors_list);
  351. transaction.run_preferences_dialog_finished.connect (on_run_preferences_dialog_finished);
  352. transaction.get_updates_finished.connect (on_get_updates_finished);
  353. // integrate progress box and term widget
  354. main_stack.add_named (transaction.term_window, "term");
  355. transaction_infobox.pack_start (transaction.progress_box);
  356. #if DISABLE_AUR
  357. #else
  358. support_aur (transaction.enable_aur);
  359. #endif
  360. display_package_queue = new Queue<string> ();
  361. main_stack.notify["visible-child"].connect (on_main_stack_visible_child_changed);
  362. filters_stack.notify["visible-child"].connect (on_filters_stack_visible_child_changed);
  363. packages_stack.notify["visible-child"].connect (on_packages_stack_visible_child_changed);
  364. properties_stack.notify["visible-child"].connect (on_properties_stack_visible_child_changed);
  365. Timeout.add (100, populate_window);
  366. }
  367. bool populate_window () {
  368. update_lists ();
  369. return false;
  370. }
  371. #if DISABLE_AUR
  372. #else
  373. void on_save_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
  374. bool enable_aur, bool search_aur, string aur_build_dir, bool check_aur_updates) {
  375. support_aur (transaction.enable_aur);
  376. }
  377. #endif
  378. void on_set_pkgreason_finished () {
  379. transaction.unlock ();
  380. transaction.refresh_handle ();
  381. refresh_packages_list ();
  382. if (main_stack.visible_child_name == "details") {
  383. if (transaction.get_installed_pkg (current_package_displayed).name != ""
  384. || transaction.get_sync_pkg (current_package_displayed).name != "") {
  385. display_package_properties (current_package_displayed);
  386. #if DISABLE_AUR
  387. #else
  388. } else {
  389. display_aur_properties (current_package_displayed);
  390. #endif
  391. }
  392. }
  393. }
  394. #if DISABLE_AUR
  395. #else
  396. void support_aur (bool enable_aur) {
  397. if (enable_aur) {
  398. packages_stackswitcher.visible = true;
  399. } else {
  400. packages_stackswitcher.visible = false;
  401. }
  402. }
  403. #endif
  404. void try_lock_and_run (TransactionAction action) {
  405. if (transaction.get_lock ()) {
  406. action ();
  407. } else {
  408. waiting = true;
  409. transaction.progress_box.action_label.label = dgettext (null, "Waiting for another package manager to quit") + "...";
  410. transaction.start_progressbar_pulse ();
  411. cancel_button.sensitive = true;
  412. transaction_infobox.show_all ();
  413. Timeout.add (5000, () => {
  414. bool locked = transaction.get_lock ();
  415. if (locked) {
  416. waiting = false;
  417. transaction.stop_progressbar_pulse ();
  418. action ();
  419. }
  420. return !locked;
  421. });
  422. }
  423. }
  424. void set_pendings_operations () {
  425. if (!transaction_running && !generate_mirrors_list && !refreshing && !sysupgrade_running) {
  426. if (filters_stack.visible_child_name == "updates") {
  427. uint64 total_dsize = 0;
  428. packages_list.foreach ((model, path, iter) => {
  429. string name;
  430. uint64 dsize;
  431. packages_list.get (iter, 1, out name, 5, out dsize);
  432. if (transaction.to_update.contains (name)) {
  433. total_dsize += dsize;
  434. }
  435. return false;
  436. });
  437. if (total_dsize > 0) {
  438. transaction.progress_box.action_label.set_markup("<b>%s: %s</b>".printf (dgettext (null, "Total download size"), format_size (total_dsize)));
  439. } else {
  440. transaction.progress_box.action_label.label = "";
  441. }
  442. if (!transaction_running && !generate_mirrors_list && !refreshing && !sysupgrade_running
  443. && (transaction.to_update.length > 0)) {
  444. apply_button.sensitive = true;
  445. } else {
  446. apply_button.sensitive = false;
  447. }
  448. cancel_button.sensitive = false;
  449. // fix an possible visibility issue
  450. transaction_infobox.show_all ();
  451. } else {
  452. #if DISABLE_AUR
  453. uint total_pending = transaction.to_install.length + transaction.to_remove.length;
  454. #else
  455. uint total_pending = transaction.to_install.length + transaction.to_remove.length + transaction.to_build.length;
  456. #endif
  457. if (total_pending == 0) {
  458. transaction.progress_box.action_label.label = "";
  459. cancel_button.sensitive = false;
  460. apply_button.sensitive = false;
  461. if (important_details) {
  462. transaction_infobox.show_all ();
  463. }
  464. } else {
  465. string info = dngettext (null, "%u pending operation", "%u pending operations", total_pending).printf (total_pending);
  466. transaction.progress_box.action_label.label = info;
  467. cancel_button.sensitive = true;
  468. apply_button.sensitive = true;
  469. // fix an possible visibility issue
  470. transaction_infobox.show_all ();
  471. }
  472. }
  473. }
  474. }
  475. public void show_default_pkgs () {
  476. this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
  477. transaction.get_installed_pkgs.begin ((obj, res) => {
  478. populate_packages_list (transaction.get_installed_pkgs.end (res));
  479. });
  480. }
  481. void update_lists () {
  482. Gtk.TreeIter iter;
  483. Gtk.TreeSelection selection = repos_treeview.get_selection ();
  484. selection.changed.disconnect (on_repos_treeview_selection_changed);
  485. foreach (unowned string repo in transaction.get_repos_names ()) {
  486. repos_list.insert_with_values (null, -1, 0, repo);
  487. }
  488. repos_list.get_iter_first (out iter);
  489. selection.select_iter (iter);
  490. selection.changed.connect_after (on_repos_treeview_selection_changed);
  491. selection = groups_treeview.get_selection ();
  492. selection.changed.disconnect (on_groups_treeview_selection_changed);
  493. foreach (unowned string group in transaction.get_groups_names ()) {
  494. groups_list.insert_with_values (null, -1, 0, group);
  495. }
  496. groups_list.set_sort_column_id (0, Gtk.SortType.ASCENDING);
  497. groups_list.get_iter_first (out iter);
  498. selection.select_iter (iter);
  499. selection.changed.connect_after (on_groups_treeview_selection_changed);
  500. selection = states_treeview.get_selection ();
  501. selection.changed.disconnect (on_states_treeview_selection_changed);
  502. states_list.insert_with_values (null, -1, 0, dgettext (null, "Installed"));
  503. states_list.insert_with_values (null, -1, 0, dgettext (null, "Explicitly installed"));
  504. states_list.insert_with_values (null, -1, 0, dgettext (null, "Orphans"));
  505. states_list.insert_with_values (null, -1, 0, dgettext (null, "Foreign"));
  506. states_list.insert_with_values (null, -1, 0, dgettext (null, "Pending"));
  507. states_list.get_iter_first (out iter);
  508. selection.select_iter (iter);
  509. selection.changed.connect_after (on_states_treeview_selection_changed);
  510. }
  511. void on_mark_explicit_button_clicked (Gtk.Button button) {
  512. if (transaction.get_lock ()) {
  513. transaction.start_set_pkgreason (current_package_displayed, 0); //Alpm.Package.Reason.EXPLICIT
  514. }
  515. }
  516. Gtk.Widget populate_details_grid (string detail_type, string detail, Gtk.Widget? previous_widget) {
  517. var label = new Gtk.Label ("<b>%s</b>".printf (detail_type + ":"));
  518. label.use_markup = true;
  519. label.halign = Gtk.Align.START;
  520. details_grid.attach_next_to (label, previous_widget, Gtk.PositionType.BOTTOM);
  521. if (!transaction_running
  522. && !sysupgrade_running
  523. && detail_type == dgettext (null, "Install Reason")
  524. && detail == dgettext (null, "Installed as a dependency for another package")) {
  525. var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 12);
  526. box.homogeneous = false;
  527. box.hexpand = true;
  528. var label2 = new Gtk.Label (detail);
  529. label2.halign = Gtk.Align.START;
  530. box.pack_start (label2, false);
  531. var mark_explicit_button = new Gtk.Button.with_label (dgettext (null, "Mark as explicitly installed"));
  532. mark_explicit_button.margin = 3;
  533. mark_explicit_button.clicked.connect (on_mark_explicit_button_clicked);
  534. box.pack_end (mark_explicit_button, false);
  535. details_grid.attach_next_to (box, label, Gtk.PositionType.RIGHT);
  536. } else {
  537. var label2 = new Gtk.Label (detail);
  538. label2.use_markup = true;
  539. label2.halign = Gtk.Align.START;
  540. details_grid.attach_next_to (label2, label, Gtk.PositionType.RIGHT);
  541. }
  542. return label as Gtk.Widget;
  543. }
  544. string find_install_button_dep_name (Gtk.Button button) {
  545. string dep_name = "";
  546. Gtk.Container container = button.get_parent ();
  547. container.foreach ((widget) => {
  548. if (widget.name == "GtkButton") {
  549. var dep_button = widget as Gtk.Button;
  550. AlpmPackage pkg = transaction.find_sync_satisfier (dep_button.label);
  551. if (pkg.name != "") {
  552. dep_name = pkg.name;
  553. }
  554. }
  555. });
  556. return dep_name;
  557. }
  558. void on_install_dep_button_toggled (Gtk.ToggleButton button) {
  559. string dep_name = find_install_button_dep_name (button);
  560. if (button.active) {
  561. button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
  562. transaction.to_install.add (dep_name);
  563. } else {
  564. button.get_style_context ().remove_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
  565. transaction.to_install.remove (dep_name);
  566. }
  567. set_pendings_operations ();
  568. }
  569. Gtk.Widget populate_dep_grid (string dep_type, string[] dep_list, Gtk.Widget? previous_widget, bool add_install_button = false) {
  570. var label = new Gtk.Label ("<b>%s</b>".printf (dep_type + ":"));
  571. label.use_markup = true;
  572. label.halign = Gtk.Align.START;
  573. label.valign = Gtk.Align.START;
  574. label.margin_top = 6;
  575. deps_grid.attach_next_to (label, previous_widget, Gtk.PositionType.BOTTOM);
  576. var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 3);
  577. box.hexpand = true;
  578. foreach (unowned string dep in dep_list) {
  579. if (add_install_button) {
  580. var box2 = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 12);
  581. box2.homogeneous = false;
  582. var dep_button = new Gtk.Button.with_label (dep);
  583. dep_button.relief = Gtk.ReliefStyle.NONE;
  584. dep_button.clicked.connect (on_dep_button_clicked);
  585. box2.pack_start (dep_button, false);
  586. if (transaction.find_installed_satisfier (dep).name == "") {
  587. var install_dep_button = new Gtk.ToggleButton.with_label (dgettext (null, "Install"));
  588. install_dep_button.margin = 3;
  589. install_dep_button.toggled.connect (on_install_dep_button_toggled);
  590. box2.pack_end (install_dep_button, false);
  591. string dep_name = find_install_button_dep_name (install_dep_button);
  592. install_dep_button.active = (dep_name in transaction.to_install);
  593. }
  594. box.pack_start (box2);
  595. } else {
  596. var dep_button = new Gtk.Button.with_label (dep);
  597. dep_button.relief = Gtk.ReliefStyle.NONE;
  598. dep_button.halign = Gtk.Align.START;
  599. dep_button.clicked.connect (on_dep_button_clicked);
  600. box.pack_start (dep_button, false);
  601. }
  602. }
  603. deps_grid.attach_next_to (box, label, Gtk.PositionType.RIGHT);
  604. return label as Gtk.Widget;
  605. }
  606. void destroy_widget (Gtk.Widget widget) {
  607. widget.destroy ();
  608. }
  609. void set_package_details (string pkgname) {
  610. AlpmPackageDetails details = transaction.get_pkg_details (pkgname);
  611. // infos
  612. name_label.set_markup ("<big><b>%s %s</b></big>".printf (details.name, details.version));
  613. desc_label.set_text (details.desc);
  614. string escaped_url = Markup.escape_text (details.url);
  615. link_label.set_markup ("<a href=\"%s\">%s</a>".printf (escaped_url, escaped_url));
  616. StringBuilder licenses = new StringBuilder ();
  617. licenses.append (dgettext (null, "Licenses"));
  618. licenses.append (":");
  619. foreach (unowned string license in details.licenses) {
  620. licenses.append (" ");
  621. licenses.append (license);
  622. }
  623. licenses_label.set_text (licenses.str);
  624. if (details.origin == 2) { //Alpm.Package.From.LOCALDB
  625. install_togglebutton.visible = false;
  626. remove_togglebutton.visible = true;
  627. remove_togglebutton.active = transaction.to_remove.contains (details.name);
  628. reinstall_togglebutton.visible = false;
  629. AlpmPackage find_pkg = transaction.get_sync_pkg (details.name);
  630. if (find_pkg.name != "") {
  631. if (find_pkg.version == details.version) {
  632. reinstall_togglebutton.visible = true;
  633. reinstall_togglebutton.active = transaction.to_install.contains (details.name);
  634. }
  635. #if DISABLE_AUR
  636. #else
  637. } else {
  638. transaction.get_aur_details.begin (details.name, (obj, res) => {
  639. AURPackageDetails aur_details = transaction.get_aur_details.end (res);
  640. if (aur_details.name != "") {
  641. // always show reinstall button for VCS package
  642. if (aur_details.name.has_suffix ("-git") ||
  643. aur_details.name.has_suffix ("-svn") ||
  644. aur_details.name.has_suffix ("-bzr") ||
  645. aur_details.name.has_suffix ("-hg") ||
  646. aur_details.version == details.version) {
  647. reinstall_togglebutton.visible = true;
  648. reinstall_togglebutton.active = transaction.to_build.contains (details.name);
  649. }
  650. }
  651. });
  652. #endif
  653. }
  654. } else if (details.origin == 3) { //Alpm.Package.From.SYNCDB
  655. remove_togglebutton.visible = false;
  656. reinstall_togglebutton.visible = false;
  657. install_togglebutton.visible = true;
  658. install_togglebutton.active = transaction.to_install.contains (details.name);
  659. }
  660. // details
  661. details_grid.foreach (destroy_widget);
  662. Gtk.Widget? previous_widget = null;
  663. if (details.repo != "") {
  664. previous_widget = populate_details_grid (dgettext (null, "Repository"), details.repo, previous_widget);
  665. }
  666. if (uint64.parse(details.downloadsize) > 0) {
  667. previous_widget = populate_details_grid (dgettext (null, "Download size"), GLib.format_size(uint64.parse(details.downloadsize)).to_string (), previous_widget);
  668. }
  669. if (uint64.parse(details.installsize) > 0) {
  670. previous_widget = populate_details_grid (dgettext (null, "Installed size"), GLib.format_size(uint64.parse(details.installsize)).to_string (), previous_widget);
  671. }
  672. if (details.groups.length > 0) {
  673. var label = new Gtk.Label ("<b>%s</b>".printf (dgettext (null, "Groups") + ":"));
  674. label.use_markup = true;
  675. label.halign = Gtk.Align.START;
  676. label.valign = Gtk.Align.START;
  677. details_grid.attach_next_to (label, previous_widget, Gtk.PositionType.BOTTOM);
  678. var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
  679. foreach (unowned string name in details.groups) {
  680. var label2 = new Gtk.Label (name);
  681. label2.halign = Gtk.Align.START;
  682. box.pack_start (label2);
  683. }
  684. details_grid.attach_next_to (box, label, Gtk.PositionType.RIGHT);
  685. previous_widget = label as Gtk.Widget;
  686. }
  687. // make packager mail clickable
  688. string[] splitted = details.packager.split ("<", 2);
  689. string packager_name = splitted[0];
  690. if (splitted.length > 1) {
  691. string packager_mail = splitted[1].split (">", 2)[0];
  692. string packager_detail = "%s <a href=\"mailto:%s\">%s</a>".printf (packager_name, packager_mail, packager_mail);
  693. previous_widget = populate_details_grid (dgettext (null, "Packager"), packager_detail, previous_widget);
  694. } else {
  695. previous_widget = populate_details_grid (dgettext (null, "Packager"), details.packager, previous_widget);
  696. }
  697. previous_widget = populate_details_grid (dgettext (null, "Build Date"), details.builddate, previous_widget);
  698. if (details.installdate != "") {
  699. previous_widget = populate_details_grid (dgettext (null, "Install Date"), details.installdate, previous_widget);
  700. }
  701. if (details.reason != "") {
  702. previous_widget = populate_details_grid (dgettext (null, "Install Reason"), details.reason, previous_widget);
  703. }
  704. if (details.has_signature != "") {
  705. previous_widget = populate_details_grid (dgettext (null, "Signatures"), details.has_signature, previous_widget);
  706. }
  707. if (details.backups.length > 0) {
  708. var label = new Gtk.Label ("<b>%s</b>".printf (dgettext (null, "Backup files") + ":"));
  709. label.use_markup = true;
  710. label.halign = Gtk.Align.START;
  711. label.valign = Gtk.Align.START;
  712. details_grid.attach_next_to (label, previous_widget, Gtk.PositionType.BOTTOM);
  713. var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12);
  714. foreach (unowned string name in details.backups) {
  715. var label2 = new Gtk.Label (name);
  716. label2.halign = Gtk.Align.START;
  717. box.pack_start (label2);
  718. }
  719. details_grid.attach_next_to (box, label, Gtk.PositionType.RIGHT);
  720. }
  721. details_grid.show_all ();
  722. // deps
  723. deps_grid.foreach (destroy_widget);
  724. previous_widget = null;
  725. if (details.depends.length > 0) {
  726. previous_widget = populate_dep_grid (dgettext (null, "Depends On"), details.depends, previous_widget);
  727. }
  728. if (details.optdepends.length > 0) {
  729. previous_widget = populate_dep_grid (dgettext (null, "Optional Dependencies"), details.optdepends, previous_widget, true);
  730. }
  731. if (details.requiredby.length > 0) {
  732. previous_widget = populate_dep_grid (dgettext (null, "Required By"), details.requiredby, previous_widget);
  733. }
  734. if (details.optionalfor.length > 0) {
  735. previous_widget = populate_dep_grid (dgettext (null, "Optional For"), details.optionalfor, previous_widget);
  736. }
  737. if (details.provides.length > 0) {
  738. var label = new Gtk.Label ("<b>%s</b>".printf (dgettext (null, "Provides") + ":"));
  739. label.use_markup = true;
  740. label.halign = Gtk.Align.START;
  741. label.valign = Gtk.Align.START;
  742. label.margin_top = 6;
  743. deps_grid.attach_next_to (label, previous_widget, Gtk.PositionType.BOTTOM);
  744. var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12);
  745. box.margin = 3;
  746. foreach (unowned string name in details.provides) {
  747. var label2 = new Gtk.Label (name);
  748. label2.halign = Gtk.Align.START;
  749. label2.margin_start = 12;
  750. box.pack_start (label2);
  751. }
  752. deps_grid.attach_next_to (box, label, Gtk.PositionType.RIGHT);
  753. previous_widget = label as Gtk.Widget;
  754. }
  755. if (details.replaces.length > 0) {
  756. previous_widget = populate_dep_grid (dgettext (null, "Replaces"), details.replaces, previous_widget);
  757. }
  758. if (details.conflicts.length > 0) {
  759. previous_widget = populate_dep_grid (dgettext (null, "Conflicts With"), details.conflicts, previous_widget);
  760. }
  761. deps_grid.show_all ();
  762. // files
  763. // will be populated on properties_stack switch
  764. if (properties_stack.visible_child_name == "files") {
  765. on_properties_stack_visible_child_changed ();
  766. }
  767. }
  768. #if DISABLE_AUR
  769. #else
  770. void set_aur_details (string pkgname) {
  771. name_label.set_text ("");
  772. desc_label.set_text ("");
  773. link_label.set_text ("");
  774. licenses_label.set_text ("");
  775. remove_togglebutton.visible = false;
  776. reinstall_togglebutton.visible = false;
  777. install_togglebutton.visible = false;
  778. properties_stackswitcher.visible = false;
  779. details_grid.foreach (destroy_widget);
  780. deps_grid.foreach (destroy_widget);
  781. this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
  782. while (Gtk.events_pending ()) {
  783. Gtk.main_iteration ();
  784. }
  785. transaction.get_aur_details.begin (pkgname, (obj, res) => {
  786. AURPackageDetails details = transaction.get_aur_details.end (res);
  787. // infos
  788. name_label.set_markup ("<big><b>%s %s</b></big>".printf (details.name, details.version));
  789. desc_label.set_text (details.desc);
  790. string aur_url = "http://aur.archlinux.org/packages/" + details.name;
  791. string escaped_url = Markup.escape_text (details.url);
  792. link_label.set_markup ("<a href=\"%s\">%s</a>\n\n<a href=\"%s\">%s</a>".printf (escaped_url, escaped_url, aur_url, aur_url));
  793. StringBuilder licenses = new StringBuilder ();
  794. licenses.append (dgettext (null, "Licenses"));
  795. licenses.append (":");
  796. foreach (unowned string license in details.licenses) {
  797. licenses.append (" ");
  798. licenses.append (license);
  799. }
  800. licenses_label.set_text (licenses.str);
  801. install_togglebutton.visible = true;
  802. install_togglebutton.active = transaction.to_build.contains (details.name);
  803. AlpmPackage pkg = transaction.get_installed_pkg (details.name);
  804. if (pkg.name != "") {
  805. remove_togglebutton.visible = true;
  806. remove_togglebutton.active = transaction.to_remove.contains (pkg.name);
  807. }
  808. // details
  809. properties_stackswitcher.visible = true;
  810. details_grid.foreach (destroy_widget);
  811. Gtk.Widget? previous_widget = null;
  812. if (details.packagebase != details.name) {
  813. previous_widget = populate_details_grid (dgettext (null, "Package Base"), details.packagebase, previous_widget);
  814. }
  815. if (details.maintainer != "") {
  816. previous_widget = populate_details_grid (dgettext (null, "Maintainer"), details.maintainer, previous_widget);
  817. }
  818. GLib.Time time = GLib.Time.local ((time_t) details.firstsubmitted);
  819. previous_widget = populate_details_grid (dgettext (null, "First Submitted"), time.format ("%a %d %b %Y %X %Z"), previous_widget);
  820. time = GLib.Time.local ((time_t) details.lastmodified);
  821. previous_widget = populate_details_grid (dgettext (null, "Last Modified"), time.format ("%a %d %b %Y %X %Z"), previous_widget);
  822. previous_widget = populate_details_grid (dgettext (null, "Votes"), details.numvotes.to_string (), previous_widget);
  823. if (details.outofdate != 0) {
  824. time = GLib.Time.local ((time_t) details.outofdate);
  825. previous_widget = populate_details_grid (dgettext (null, "Out of Date"), time.format ("%a %d %b %Y %X %Z"), previous_widget);
  826. }
  827. details_grid.show_all ();
  828. // deps
  829. previous_widget = null;
  830. if (details.depends.length > 0) {
  831. previous_widget = populate_dep_grid (dgettext (null, "Depends On"), details.depends, previous_widget);
  832. }
  833. if (details.makedepends.length > 0) {
  834. previous_widget = populate_dep_grid (dgettext (null, "Make Dependencies"), details.makedepends, previous_widget);
  835. }
  836. if (details.checkdepends.length > 0) {
  837. previous_widget = populate_dep_grid (dgettext (null, "Check Dependencies"), details.checkdepends, previous_widget);
  838. }
  839. if (details.optdepends.length > 0) {
  840. previous_widget = populate_dep_grid (dgettext (null, "Optional Dependencies"), details.optdepends, previous_widget);
  841. }
  842. if (details.provides.length > 0) {
  843. var label = new Gtk.Label ("<b>%s</b>".printf (dgettext (null, "Provides") + ":"));
  844. label.use_markup = true;
  845. label.halign = Gtk.Align.START;
  846. label.valign = Gtk.Align.START;
  847. label.margin_top = 6;
  848. deps_grid.attach_next_to (label, previous_widget, Gtk.PositionType.BOTTOM);
  849. var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12);
  850. box.margin = 3;
  851. foreach (unowned string name in details.provides) {
  852. var label2 = new Gtk.Label (name);
  853. label2.halign = Gtk.Align.START;
  854. label2.margin_start = 12;
  855. box.pack_start (label2);
  856. }
  857. deps_grid.attach_next_to (box, label, Gtk.PositionType.RIGHT);
  858. previous_widget = label as Gtk.Widget;
  859. }
  860. if (details.replaces.length > 0) {
  861. previous_widget = populate_dep_grid (dgettext (null, "Replaces"), details.replaces, previous_widget);
  862. }
  863. if (details.conflicts.length > 0) {
  864. previous_widget = populate_dep_grid (dgettext (null, "Conflicts With"), details.conflicts, previous_widget);
  865. }
  866. deps_grid.show_all ();
  867. this.get_window ().set_cursor (null);
  868. });
  869. }
  870. #endif
  871. [GtkCallback]
  872. void on_install_togglebutton_toggled () {
  873. if (install_togglebutton.active) {
  874. install_togglebutton.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
  875. if (transaction.get_pkg_origin (current_package_displayed) == 3) { //Alpm.Package.From.SYNCDB
  876. transaction.to_install.add (current_package_displayed);
  877. #if DISABLE_AUR
  878. #else
  879. } else {
  880. transaction.to_build.add (current_package_displayed);
  881. #endif
  882. }
  883. } else {
  884. install_togglebutton.get_style_context ().remove_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
  885. if (transaction.to_install.remove (current_package_displayed)) {
  886. #if DISABLE_AUR
  887. #else
  888. } else {
  889. transaction.to_build.remove (current_package_displayed);
  890. #endif
  891. }
  892. }
  893. set_pendings_operations ();
  894. }
  895. [GtkCallback]
  896. void on_remove_togglebutton_toggled () {
  897. if (remove_togglebutton.active) {
  898. reinstall_togglebutton.active = false;
  899. reinstall_togglebutton.get_style_context ().remove_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
  900. remove_togglebutton.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
  901. transaction.to_install.remove (current_package_displayed);
  902. transaction.to_remove.add (current_package_displayed);
  903. } else {
  904. remove_togglebutton.get_style_context ().remove_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
  905. transaction.to_remove.remove (current_package_displayed);
  906. }
  907. set_pendings_operations ();
  908. }
  909. [GtkCallback]
  910. void on_reinstall_togglebutton_toggled () {
  911. if (reinstall_togglebutton.active) {
  912. remove_togglebutton.active = false;
  913. remove_togglebutton.get_style_context ().remove_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
  914. reinstall_togglebutton.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
  915. transaction.to_remove.remove (current_package_displayed);
  916. AlpmPackage find_pkg = transaction.get_sync_pkg (current_package_displayed);
  917. if (find_pkg.name != "") {
  918. transaction.to_install.add (current_package_displayed);
  919. #if DISABLE_AUR
  920. #else
  921. } else {
  922. // availability in AUR was checked in set_package_details
  923. transaction.to_build.add (current_package_displayed);
  924. #endif
  925. }
  926. } else {
  927. reinstall_togglebutton.get_style_context ().remove_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
  928. transaction.to_install.remove (current_package_displayed);
  929. #if DISABLE_AUR
  930. #else
  931. transaction.to_build.remove (current_package_displayed);
  932. #endif
  933. }
  934. set_pendings_operations ();
  935. }
  936. void populate_packages_list (AlpmPackage[] pkgs) {
  937. // populate liststore
  938. packages_treeview.freeze_notify ();
  939. packages_treeview.freeze_child_notify ();
  940. packages_list.clear ();
  941. foreach (unowned AlpmPackage pkg in pkgs) {
  942. string version;
  943. uint64 size;
  944. string size_str;
  945. if (filters_stack.visible_child_name == "updates") {
  946. version = "<b>%s</b>\n(%s)".printf (pkg.version, pkg.installed_version);
  947. size = pkg.download_size;
  948. size_str = pkg.download_size == 0 ? "" : GLib.format_size (pkg.download_size);
  949. } else {
  950. version = pkg.version;
  951. size = pkg.size;
  952. size_str = GLib.format_size (pkg.size);
  953. }
  954. packages_list.insert_with_values (null, -1,
  955. 0, pkg.origin,
  956. 1, pkg.name,
  957. 2, "<b>%s</b>\n%s".printf (pkg.name, Markup.escape_text (pkg.desc)),
  958. 3, version,
  959. 4, pkg.repo,
  960. 5, size,
  961. 6, size_str);
  962. }
  963. packages_treeview.thaw_child_notify ();
  964. packages_treeview.thaw_notify ();
  965. this.get_window ().set_cursor (null);
  966. }
  967. #if DISABLE_AUR
  968. #else
  969. void populate_aur_list (AURPackage[] pkgs) {
  970. // populate liststore
  971. aur_treeview.freeze_notify ();
  972. aur_treeview.freeze_child_notify ();
  973. aur_list.clear ();
  974. foreach (unowned AURPackage aur_pkg in pkgs) {
  975. string version;
  976. if (filters_stack.visible_child_name == "updates") {
  977. version = "<b>%s</b>\n(%s)".printf (aur_pkg.version, aur_pkg.installed_version);
  978. } else if (aur_pkg.installed_version == "") {
  979. version = aur_pkg.version;
  980. } else {
  981. version = aur_pkg.installed_version;
  982. }
  983. aur_list.insert_with_values (null, -1,
  984. 0, aur_pkg.installed_version == "" ? 0 : 2, //Alpm.Package.From.LOCALDB
  985. 1, aur_pkg.name,
  986. 2, "<b>%s</b>\n%s".printf (aur_pkg.name, Markup.escape_text (aur_pkg.desc)),
  987. 3, version,
  988. 4, aur_pkg.popularity,
  989. 5, "%.2f".printf (aur_pkg.popularity));
  990. }
  991. aur_treeview.thaw_child_notify ();
  992. aur_treeview.thaw_notify ();
  993. this.get_window ().set_cursor (null);
  994. }
  995. #endif
  996. void refresh_packages_list () {
  997. switch (filters_stack.visible_child_name) {
  998. case "search":
  999. #if DISABLE_AUR
  1000. #else
  1001. aur_list.clear ();
  1002. #endif
  1003. filters_stack.visible = true;
  1004. set_pendings_operations ();
  1005. #if DISABLE_AUR
  1006. #else
  1007. packages_stackswitcher.visible = transaction.enable_aur;
  1008. #endif
  1009. if (packages_stack.visible_child_name == "updated") {
  1010. packages_stack.visible_child_name = "repos";
  1011. }
  1012. Gtk.TreeSelection selection = search_treeview.get_selection ();
  1013. if (selection.get_selected (null, null)) {
  1014. on_search_treeview_selection_changed ();
  1015. } else {
  1016. show_default_pkgs ();
  1017. search_entry.grab_focus ();
  1018. }
  1019. break;
  1020. case "groups":
  1021. filters_stack.visible = true;
  1022. set_pendings_operations ();
  1023. packages_stack.visible_child_name = "repos";
  1024. packages_stackswitcher.visible = false;
  1025. on_groups_treeview_selection_changed ();
  1026. break;
  1027. case "states":
  1028. filters_stack.visible = true;
  1029. set_pendings_operations ();
  1030. packages_stack.visible_child_name = "repos";
  1031. packages_stackswitcher.visible = false;
  1032. on_states_treeview_selection_changed ();
  1033. break;
  1034. case "repos":
  1035. filters_stack.visible = true;
  1036. set_pendings_operations ();
  1037. packages_stack.visible_child_name = "repos";
  1038. packages_stackswitcher.visible = false;
  1039. on_repos_treeview_selection_changed ();
  1040. break;
  1041. case "updates":
  1042. packages_list.clear ();
  1043. #if DISABLE_AUR
  1044. #else
  1045. aur_list.clear ();
  1046. #endif
  1047. var attention_val = GLib.Value (typeof (bool));
  1048. attention_val.set_boolean (false);
  1049. filters_stack.child_set_property (filters_stack.get_child_by_name ("updates"),
  1050. "needs-attention",
  1051. attention_val);
  1052. filters_stack.visible = false;
  1053. packages_stack.visible_child_name = "repos";
  1054. packages_stackswitcher.visible = false;
  1055. apply_button.visible = false;
  1056. this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
  1057. transaction.start_get_updates ();
  1058. break;
  1059. default:
  1060. break;
  1061. }
  1062. }
  1063. void display_package_properties (string pkgname) {
  1064. current_package_displayed = pkgname;
  1065. files_scrolledwindow.visible = true;
  1066. set_package_details (current_package_displayed);
  1067. }
  1068. #if DISABLE_AUR
  1069. #else
  1070. void display_aur_properties (string pkgname) {
  1071. current_package_displayed = pkgname;
  1072. files_scrolledwindow.visible = false;
  1073. set_aur_details (current_package_displayed);
  1074. }
  1075. #endif
  1076. [GtkCallback]
  1077. void on_packages_treeview_row_activated (Gtk.TreeView treeview, Gtk.TreePath path, Gtk.TreeViewColumn column) {
  1078. if (column.title == dgettext (null, "Name")) {
  1079. this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
  1080. while (Gtk.events_pending ()) {
  1081. Gtk.main_iteration ();
  1082. }
  1083. main_stack.visible_child_name = "details";
  1084. Gtk.TreeIter iter;
  1085. packages_list.get_iter (out iter, path);
  1086. string pkgname;
  1087. packages_list.get (iter, 1, out pkgname);
  1088. display_package_properties (pkgname);
  1089. this.get_window ().set_cursor (null);
  1090. }
  1091. }
  1092. void on_dep_button_clicked (Gtk.Button button) {
  1093. if (display_package_queue.find_custom (current_package_displayed, strcmp) == null) {
  1094. display_package_queue.push_tail (current_package_displayed);
  1095. }
  1096. string depstring = button.label;
  1097. // if depstring contains a version restriction search a satisfier directly
  1098. if (">" in depstring || "=" in depstring || "<" in depstring) {
  1099. var pkg = transaction.find_installed_satisfier (depstring);
  1100. if (pkg.name != "") {
  1101. display_package_properties (pkg.name);
  1102. } else {
  1103. pkg = transaction.find_sync_satisfier (depstring);
  1104. if (pkg.name != "") {
  1105. display_package_properties (pkg.name);
  1106. }
  1107. }
  1108. } else {
  1109. // just search for the name first to search for AUR after
  1110. if (transaction.get_installed_pkg (depstring).name != "") {
  1111. display_package_properties (depstring);
  1112. } else if (transaction.get_sync_pkg (depstring).name != "") {
  1113. display_package_properties (depstring);
  1114. } else {
  1115. this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
  1116. while (Gtk.events_pending ()) {
  1117. Gtk.main_iteration ();
  1118. }
  1119. #if DISABLE_AUR
  1120. #else
  1121. transaction.get_aur_details.begin (depstring, (obj, res) => {
  1122. this.get_window ().set_cursor (null);
  1123. if (transaction.get_aur_details.end (res).name != "") {
  1124. display_aur_properties (depstring);
  1125. } else {
  1126. var pkg = transaction.find_installed_satisfier (depstring);
  1127. if (pkg.name != "") {
  1128. display_package_properties (pkg.name);
  1129. } else {
  1130. pkg = transaction.find_sync_satisfier (depstring);
  1131. if (pkg.name != "") {
  1132. display_package_properties (pkg.name);
  1133. }
  1134. }
  1135. }
  1136. });
  1137. #endif
  1138. }
  1139. }
  1140. }
  1141. void on_properties_stack_visible_child_changed () {
  1142. switch (properties_stack.visible_child_name) {
  1143. case "files":
  1144. this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
  1145. while (Gtk.events_pending ()) {
  1146. Gtk.main_iteration ();
  1147. }
  1148. string[] files = transaction.get_pkg_files (current_package_displayed);
  1149. StringBuilder text = new StringBuilder ();
  1150. foreach (unowned string file in files) {
  1151. if (text.len > 0) {
  1152. text.append ("\n");
  1153. }
  1154. text.append (file);
  1155. }
  1156. files_textview.buffer.set_text (text.str, (int) text.len);
  1157. this.get_window ().set_cursor (null);
  1158. break;
  1159. default:
  1160. break;
  1161. }
  1162. }
  1163. void on_packages_state_icon_activated (Gtk.TreePath path) {
  1164. Gtk.TreeIter iter;
  1165. packages_list.get_iter (out iter, path);
  1166. uint origin;
  1167. string pkgname;
  1168. packages_list.get (iter, 0, out origin, 1, out pkgname);
  1169. if (!transaction.transaction_summary.contains (pkgname)) {
  1170. if (transaction.to_install.remove (pkgname)) {
  1171. } else if (transaction.to_remove.remove (pkgname)) {
  1172. } else {
  1173. if (origin == 2) { //Alpm.Package.From.LOCALDB
  1174. if (!transaction.should_hold (pkgname)) {
  1175. transaction.to_remove.add (pkgname);
  1176. }
  1177. } else if (transaction.to_update.remove (pkgname)) {
  1178. transaction.temporary_ignorepkgs.add (pkgname);
  1179. } else if (transaction.temporary_ignorepkgs.remove (pkgname)) {
  1180. transaction.to_update.add (pkgname);
  1181. } else {
  1182. transaction.to_install.add (pkgname);
  1183. }
  1184. }
  1185. }
  1186. packages_treeview.queue_draw ();
  1187. set_pendings_operations ();
  1188. }
  1189. #if DISABLE_AUR
  1190. #else
  1191. void on_aur_treeview_row_activated (Gtk.TreeView treeview, Gtk.TreePath path, Gtk.TreeViewColumn column) {
  1192. if (column.title == dgettext (null, "Name")) {
  1193. main_stack.visible_child_name = "details";
  1194. Gtk.TreeIter iter;
  1195. aur_list.get_iter (out iter, path);
  1196. uint origin;
  1197. string pkgname;
  1198. aur_list.get (iter, 0, out origin, 1, out pkgname);
  1199. if (filters_stack.visible_child_name == "updates") {
  1200. display_aur_properties (pkgname);
  1201. } else if (origin == 2) { //Alpm.Package.From.LOCALDB
  1202. display_package_properties (pkgname);
  1203. } else {
  1204. display_aur_properties (pkgname);
  1205. }
  1206. }
  1207. }
  1208. void on_aur_state_icon_activated (Gtk.TreePath path) {
  1209. Gtk.TreeIter iter;
  1210. aur_list.get_iter (out iter, path);
  1211. uint origin;
  1212. string pkgname;
  1213. aur_list.get (iter, 0, out origin, 1, out pkgname);
  1214. if (filters_stack.visible_child_name == "updates") {
  1215. if (transaction.to_update.remove (pkgname)) {
  1216. transaction.temporary_ignorepkgs.add (pkgname);
  1217. } else if (transaction.temporary_ignorepkgs.remove (pkgname)) {
  1218. transaction.to_update.add (pkgname);
  1219. }
  1220. } else if (origin == 2) { //Alpm.Package.From.LOCALDB
  1221. if (!transaction.transaction_summary.contains (pkgname)) {
  1222. if (transaction.to_remove.remove (pkgname)) {
  1223. } else if (!transaction.should_hold (pkgname)) {
  1224. transaction.to_remove.add (pkgname);
  1225. }
  1226. }
  1227. } else if (transaction.to_build.remove (pkgname)) {
  1228. } else {
  1229. transaction.to_build.add (pkgname);
  1230. }
  1231. set_pendings_operations ();
  1232. }
  1233. #endif
  1234. [GtkCallback]
  1235. public void on_button_back_clicked () {
  1236. string? pkgname = display_package_queue.pop_tail ();
  1237. if (pkgname != null) {
  1238. AlpmPackage pkg = transaction.get_installed_pkg (pkgname);
  1239. if (pkg.name == "") {
  1240. pkg = transaction.get_sync_pkg (pkgname);
  1241. #if DISABLE_AUR
  1242. #else
  1243. }
  1244. if (pkg.name == "") {
  1245. transaction.get_aur_details.begin (pkgname, (obj, res) => {
  1246. if (transaction.get_aur_details.end (res).name != "") {
  1247. display_aur_properties (pkgname);
  1248. } else {
  1249. pkg = transaction.find_installed_satisfier (pkgname);
  1250. if (pkg.name == "") {
  1251. pkg = transaction.find_sync_satisfier (pkgname);
  1252. }
  1253. if (pkg.name != "") {
  1254. display_package_properties (pkgname);
  1255. }
  1256. }
  1257. });
  1258. #endif
  1259. } else {
  1260. display_package_properties (pkgname);
  1261. }
  1262. } else {
  1263. main_stack.visible_child_name = "browse";
  1264. }
  1265. }
  1266. void on_install_item_activate () {
  1267. foreach (unowned string pkgname in selected_pkgs) {
  1268. if (transaction.get_pkg_origin (pkgname) == 3) { //Alpm.Package.From.SYNCDB
  1269. transaction.to_install.add (pkgname);
  1270. }
  1271. }
  1272. #if DISABLE_AUR
  1273. #else
  1274. foreach (unowned string pkgname in selected_aur) {
  1275. transaction.to_build.add (pkgname);
  1276. }
  1277. #endif
  1278. set_pendings_operations ();
  1279. }
  1280. void on_details_item_activate () {
  1281. // show details for the first selected package
  1282. if (selected_pkgs.length () == 1) {
  1283. display_package_properties (selected_pkgs.data);
  1284. main_stack.visible_child_name = "details";
  1285. #if DISABLE_AUR
  1286. #else
  1287. } else if (selected_aur.length () == 1) {
  1288. display_aur_properties (selected_aur.data);
  1289. main_stack.visible_child_name = "details";
  1290. #endif
  1291. }
  1292. }
  1293. void on_remove_item_activate () {
  1294. foreach (unowned string pkgname in selected_pkgs) {
  1295. transaction.to_install.remove (pkgname);
  1296. if (!transaction.should_hold (pkgname)) {
  1297. if (transaction.get_pkg_origin (pkgname) == 2) { //Alpm.Package.From.LOCALDB
  1298. transaction.to_remove.add (pkgname);
  1299. }
  1300. }
  1301. }
  1302. set_pendings_operations ();
  1303. }
  1304. void on_deselect_item_activate () {
  1305. foreach (unowned string pkgname in selected_pkgs) {
  1306. if (transaction.to_install.remove (pkgname)) {
  1307. } else if (transaction.to_update.remove (pkgname)) {
  1308. transaction.temporary_ignorepkgs.add (pkgname);
  1309. } else {
  1310. transaction.to_remove.remove (pkgname);
  1311. }
  1312. }
  1313. #if DISABLE_AUR
  1314. #else
  1315. foreach (unowned string pkgname in selected_aur) {
  1316. if (transaction.to_build.remove (pkgname)) {
  1317. } else {
  1318. transaction.to_update.remove (pkgname);
  1319. transaction.temporary_ignorepkgs.add (pkgname);
  1320. }
  1321. }
  1322. #endif
  1323. set_pendings_operations ();
  1324. }
  1325. void on_upgrade_item_activate () {
  1326. foreach (unowned string pkgname in selected_pkgs) {
  1327. transaction.temporary_ignorepkgs.remove (pkgname);
  1328. transaction.to_update.add (pkgname);
  1329. }
  1330. #if DISABLE_AUR
  1331. #else
  1332. foreach (unowned string pkgname in selected_aur) {
  1333. transaction.temporary_ignorepkgs.remove (pkgname);
  1334. transaction.to_update.add (pkgname);
  1335. }
  1336. #endif
  1337. set_pendings_operations ();
  1338. }
  1339. void on_packages_stack_visible_child_changed () {
  1340. // do nothing if it we want to see pendings AUR operations
  1341. switch (filters_stack.visible_child_name) {
  1342. case "search":
  1343. Gtk.TreeIter iter;
  1344. Gtk.TreeSelection selection = search_treeview.get_selection ();
  1345. if (selection.get_selected (null, out iter)) {
  1346. this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
  1347. while (Gtk.events_pending ()) {
  1348. Gtk.main_iteration ();
  1349. }
  1350. string search_string;
  1351. search_list.get (iter, 0, out search_string);
  1352. switch (packages_stack.visible_child_name) {
  1353. case "repos":
  1354. transaction.search_pkgs.begin (search_string, (obj, res) => {
  1355. // get custom sort by relevance
  1356. packages_list.set_sort_column_id (Gtk.TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, 0);
  1357. populate_packages_list (transaction.search_pkgs.end (res));
  1358. });
  1359. break;
  1360. #if DISABLE_AUR
  1361. #else
  1362. case "aur":
  1363. transaction.search_in_aur.begin (search_string, (obj, res) => {
  1364. populate_aur_list (transaction.search_in_aur.end (res));
  1365. });
  1366. break;
  1367. #endif
  1368. default:
  1369. break;
  1370. }
  1371. }
  1372. break;
  1373. default:
  1374. break;
  1375. }
  1376. #if DISABLE_AUR
  1377. #else
  1378. if (packages_stack.visible_child_name == "aur") {
  1379. var attention_val = GLib.Value (typeof (bool));
  1380. attention_val.set_boolean (false);
  1381. packages_stack.child_set_property (packages_stack.get_child_by_name ("aur"),
  1382. "needs-attention",
  1383. attention_val);
  1384. }
  1385. #endif
  1386. }
  1387. [GtkCallback]
  1388. bool on_packages_treeview_button_press_event (Gdk.EventButton event) {
  1389. // Check if right mouse button was clicked
  1390. if (event.type == Gdk.EventType.BUTTON_PRESS && event.button == 3) {
  1391. Gtk.TreePath treepath;
  1392. if (packages_treeview.get_path_at_pos ((int) event.x, (int) event.y, out treepath, null, null, null)) {
  1393. packages_treeview.grab_focus ();
  1394. Gtk.TreeSelection selection = packages_treeview.get_selection ();
  1395. if (!selection.path_is_selected (treepath)) {
  1396. selection.unselect_all ();
  1397. selection.select_path (treepath);
  1398. }
  1399. GLib.List<Gtk.TreePath> selected_paths = selection.get_selected_rows (null);
  1400. selected_pkgs = new GLib.List<string> ();
  1401. #if DISABLE_AUR
  1402. #else
  1403. selected_aur = new GLib.List<string> ();
  1404. #endif
  1405. deselect_item.sensitive = false;
  1406. upgrade_item.sensitive = false;
  1407. install_item.sensitive = false;
  1408. remove_item.sensitive = false;
  1409. if (selected_paths.length () == 1) {
  1410. Gtk.TreePath path = selected_paths.data;
  1411. Gtk.TreeIter iter;
  1412. packages_list.get_iter (out iter, path);
  1413. uint origin;
  1414. string pkgname;
  1415. string pkgversion;
  1416. packages_list.get (iter, 0, out origin, 1, out pkgname, 3, out pkgversion);
  1417. selected_pkgs.append (pkgname);
  1418. details_item.sensitive = true;
  1419. if (transaction.to_install.contains (pkgname)
  1420. || transaction.to_remove.contains (pkgname)
  1421. || transaction.to_update.contains (pkgname)) {
  1422. deselect_item.sensitive = true;
  1423. } else if (transaction.temporary_ignorepkgs.contains (pkgname)) {
  1424. upgrade_item.sensitive = true;
  1425. } else if (origin == 2) { //Alpm.Package.From.LOCALDB
  1426. remove_item.sensitive = true;
  1427. } else if (origin == 3) { //Alpm.Package.From.SYNCDB
  1428. install_item.sensitive = true;
  1429. }
  1430. } else {
  1431. details_item.sensitive = false;
  1432. foreach (unowned Gtk.TreePath path in selected_paths) {
  1433. Gtk.TreeIter iter;
  1434. packages_list.get_iter (out iter, path);
  1435. uint origin;
  1436. string pkgname;
  1437. packages_list.get (iter, 0, out origin, 1, out pkgname);
  1438. selected_pkgs.append (pkgname);
  1439. if (!deselect_item.sensitive) {
  1440. if (transaction.to_install.contains (pkgname)
  1441. || transaction.to_remove.contains (pkgname)
  1442. || transaction.to_update.contains (pkgname)) {
  1443. deselect_item.sensitive = true;
  1444. }
  1445. }
  1446. if (origin == 3) { //Alpm.Package.From.SYNCDB
  1447. if (transaction.temporary_ignorepkgs.contains (pkgname)) {
  1448. upgrade_item.sensitive = true;
  1449. } else {
  1450. install_item.sensitive = true;
  1451. }
  1452. }
  1453. if (origin == 2) { //Alpm.Package.From.LOCALDB
  1454. remove_item.sensitive = true;
  1455. }
  1456. }
  1457. }
  1458. right_click_menu.popup_at_pointer (event);
  1459. return true;
  1460. }
  1461. }
  1462. return false;
  1463. }
  1464. [GtkCallback]
  1465. bool on_packages_treeview_query_tooltip (int x, int y, bool keyboard_tooltip, Gtk.Tooltip tooltip) {
  1466. Gtk.TreePath path;
  1467. Gtk.TreeIter iter;
  1468. if (packages_treeview.get_tooltip_context (ref x, ref y, keyboard_tooltip, null, out path, out iter)) {
  1469. string desc;
  1470. packages_list.get (iter, 2, out desc);
  1471. tooltip.set_markup (desc);
  1472. packages_treeview.set_tooltip_row (tooltip, path);
  1473. return true;
  1474. }
  1475. return false;
  1476. }
  1477. #if DISABLE_AUR
  1478. #else
  1479. bool on_aur_treeview_button_press_event (Gdk.EventButton event) {
  1480. aur_treeview.grab_focus ();
  1481. // Check if right mouse button was clicked
  1482. if (event.type == Gdk.EventType.BUTTON_PRESS && event.button == 3) {
  1483. Gtk.TreePath? treepath;
  1484. Gtk.TreeSelection selection = aur_treeview.get_selection ();
  1485. if (aur_treeview.get_path_at_pos ((int) event.x, (int) event.y, out treepath, null, null, null)) {
  1486. if (!selection.path_is_selected (treepath)) {
  1487. selection.unselect_all ();
  1488. selection.select_path (treepath);
  1489. }
  1490. GLib.List<Gtk.TreePath> selected_paths = selection.get_selected_rows (null);
  1491. selected_pkgs = new GLib.List<string> ();
  1492. selected_aur = new GLib.List<string> ();
  1493. deselect_item.sensitive = false;
  1494. upgrade_item.sensitive = false;
  1495. install_item.sensitive = false;
  1496. remove_item.sensitive = false;
  1497. if (selected_paths.length () == 1) {
  1498. details_item.sensitive = true;
  1499. } else {
  1500. details_item.sensitive = false;
  1501. }
  1502. foreach (unowned Gtk.TreePath path in selected_paths) {
  1503. Gtk.TreeIter iter;
  1504. aur_list.get_iter (out iter, path);
  1505. string pkgname;
  1506. aur_list.get (iter, 1, out pkgname);
  1507. AlpmPackage pkg = transaction.get_installed_pkg (pkgname);
  1508. if (pkg.name != "") {
  1509. selected_pkgs.append (pkgname);
  1510. // there is for sure a pkg to remove
  1511. if (filters_stack.visible_child_name == "search"
  1512. && !transaction.to_remove.contains (pkgname)
  1513. && !transaction.to_build.contains (pkgname)
  1514. && !transaction.to_update.contains (pkgname)) {
  1515. remove_item.sensitive = true;
  1516. }
  1517. } else {
  1518. selected_aur.append (pkgname);
  1519. }
  1520. }
  1521. foreach (unowned string pkgname in selected_aur) {
  1522. if (transaction.to_remove.contains (pkgname)
  1523. || transaction.to_build.contains (pkgname)) {
  1524. deselect_item.sensitive = true;
  1525. } else {
  1526. install_item.sensitive = true;
  1527. }
  1528. }
  1529. foreach (unowned string pkgname in selected_pkgs) {
  1530. if (transaction.to_remove.contains (pkgname)
  1531. || transaction.to_update.contains (pkgname)) {
  1532. deselect_item.sensitive = true;
  1533. } else if (transaction.temporary_ignorepkgs.contains (pkgname)) {
  1534. upgrade_item.sensitive = true;
  1535. }
  1536. }
  1537. right_click_menu.popup_at_pointer (event);
  1538. return true;
  1539. }
  1540. }
  1541. return false;
  1542. }
  1543. bool on_aur_treeview_query_tooltip (int x, int y, bool keyboard_tooltip, Gtk.Tooltip tooltip) {
  1544. Gtk.TreePath path;
  1545. Gtk.TreeIter iter;
  1546. if (aur_treeview.get_tooltip_context (ref x, ref y, keyboard_tooltip, null, out path, out iter)) {
  1547. string desc;
  1548. aur_list.get (iter, 2, out desc);
  1549. tooltip.set_markup (desc);
  1550. aur_treeview.set_tooltip_row (tooltip, path);
  1551. return true;
  1552. }
  1553. return false;
  1554. }
  1555. #endif
  1556. [GtkCallback]
  1557. void on_search_entry_activate () {
  1558. string search_string = search_entry.get_text ().strip ();
  1559. if (search_string != "") {
  1560. this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
  1561. Gtk.TreeModel model;
  1562. Gtk.TreeIter iter;
  1563. Gtk.TreeSelection selection = search_treeview.get_selection ();
  1564. // add search string in search_list if needed
  1565. bool found = false;
  1566. // check if search string is already selected in search list
  1567. if (selection.get_selected (out model, out iter)) {
  1568. string selected_string;
  1569. model.get (iter, 0, out selected_string);
  1570. if (selected_string == search_string) {
  1571. on_search_treeview_selection_changed ();
  1572. found = true;
  1573. }
  1574. }
  1575. // check if search string exists in search list
  1576. if (!found) {
  1577. search_list.foreach ((_model, _path, _iter) => {
  1578. string line;
  1579. _model.get (_iter, 0, out line);
  1580. if (line == search_string) {
  1581. found = true;
  1582. // we select the iter in search_list
  1583. // it will populate the list with the selection changed signal
  1584. selection.select_iter (_iter);
  1585. }
  1586. return found;
  1587. });
  1588. }
  1589. if (!found) {
  1590. search_list.insert_with_values (out iter, -1, 0, search_string);
  1591. // we select the iter in search_list
  1592. // it will populate the list with the selection changed signal
  1593. selection.select_iter (iter);
  1594. }
  1595. }
  1596. }
  1597. bool search_entry_timeout_callback () {
  1598. on_search_entry_activate ();
  1599. search_entry_timeout_id = 0;
  1600. return false;
  1601. }
  1602. [GtkCallback]
  1603. void on_search_entry_changed () {
  1604. if (search_entry.get_text ().strip () != "") {
  1605. if (search_entry_timeout_id != 0) {
  1606. Source.remove (search_entry_timeout_id);
  1607. }
  1608. search_entry_timeout_id = Timeout.add (750, search_entry_timeout_callback);
  1609. }
  1610. }
  1611. [GtkCallback]
  1612. void on_search_treeview_selection_changed () {
  1613. Gtk.TreeIter iter;
  1614. Gtk.TreeSelection selection = search_treeview.get_selection ();
  1615. if (selection.get_selected (null, out iter)) {
  1616. this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
  1617. string search_string;
  1618. search_list.get (iter, 0, out search_string);
  1619. // change search entry text to the selected one
  1620. search_entry.changed.disconnect (on_search_entry_changed);
  1621. search_entry.set_text (search_string);
  1622. search_entry.changed.connect (on_search_entry_changed);
  1623. Timeout.add (200, () => {
  1624. search_entry.grab_focus_without_selecting ();
  1625. return false;
  1626. });
  1627. search_entry.set_position (-1);
  1628. switch (packages_stack.visible_child_name) {
  1629. case "repos":
  1630. transaction.search_pkgs.begin (search_string, (obj, res) => {
  1631. var pkgs = transaction.search_pkgs.end (res);
  1632. // get custom sort by relevance
  1633. packages_list.set_sort_column_id (Gtk.TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, 0);
  1634. populate_packages_list (pkgs);
  1635. #if DISABLE_AUR
  1636. #else
  1637. if (transaction.search_aur) {
  1638. if (pkgs.length == 0) {
  1639. transaction.search_in_aur.begin (search_string, (obj, res) => {
  1640. if (transaction.search_in_aur.end (res).length != 0) {
  1641. packages_stack.visible_child_name = "aur";
  1642. }
  1643. });
  1644. } else {
  1645. transaction.search_in_aur.begin (search_string, (obj, res) => {
  1646. if (transaction.search_in_aur.end (res).length != 0) {
  1647. var attention_val = GLib.Value (typeof (bool));
  1648. attention_val.set_boolean (true);
  1649. packages_stack.child_set_property (packages_stack.get_child_by_name ("aur"),
  1650. "needs-attention",
  1651. attention_val);
  1652. }
  1653. });
  1654. }
  1655. }
  1656. #endif
  1657. });
  1658. #if DISABLE_AUR
  1659. #else
  1660. aur_list.clear ();
  1661. #endif
  1662. break;
  1663. #if DISABLE_AUR
  1664. #else
  1665. case "aur":
  1666. transaction.search_in_aur.begin (search_string, (obj, res) => {
  1667. populate_aur_list (transaction.search_in_aur.end (res));
  1668. });
  1669. packages_list.clear ();
  1670. break;
  1671. #endif
  1672. default:
  1673. break;
  1674. }
  1675. }
  1676. }
  1677. [GtkCallback]
  1678. void on_groups_treeview_selection_changed () {
  1679. Gtk.TreeIter iter;
  1680. Gtk.TreeSelection selection = groups_treeview.get_selection ();
  1681. if (selection.get_selected (null, out iter)) {
  1682. this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
  1683. string group_name;
  1684. groups_list.get (iter, 0, out group_name);
  1685. transaction.get_group_pkgs.begin (group_name, (obj, res) => {
  1686. populate_packages_list (transaction.get_group_pkgs.end (res));
  1687. });
  1688. }
  1689. }
  1690. [GtkCallback]
  1691. void on_states_treeview_selection_changed () {
  1692. Gtk.TreeIter iter;
  1693. Gtk.TreeSelection selection = states_treeview.get_selection ();
  1694. if (selection.get_selected (null, out iter)) {
  1695. this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
  1696. packages_stackswitcher.visible = false;
  1697. string state;
  1698. states_list.get (iter, 0, out state);
  1699. if (state == dgettext (null, "Installed")) {
  1700. transaction.get_installed_pkgs.begin ((obj, res) => {
  1701. populate_packages_list (transaction.get_installed_pkgs.end (res));
  1702. });
  1703. } else if (state == dgettext (null, "Explicitly installed")) {
  1704. transaction.get_explicitly_installed_pkgs.begin ((obj, res) => {
  1705. populate_packages_list (transaction.get_explicitly_installed_pkgs.end (res));
  1706. });
  1707. } else if (state == dgettext (null, "Orphans")) {
  1708. transaction.get_orphans.begin ((obj, res) => {
  1709. populate_packages_list (transaction.get_orphans.end (res));
  1710. });
  1711. } else if (state == dgettext (null, "Foreign")) {
  1712. transaction.get_foreign_pkgs.begin ((obj, res) => {
  1713. populate_packages_list (transaction.get_foreign_pkgs.end (res));
  1714. });
  1715. } else if (state == dgettext (null, "Pending")) {
  1716. AlpmPackage[] pkgs = {};
  1717. foreach (unowned string pkgname in transaction.to_install) {
  1718. AlpmPackage pkg = transaction.get_installed_pkg (pkgname);
  1719. if (pkg.name == "") {
  1720. pkg = transaction.get_sync_pkg (pkgname);
  1721. }
  1722. if (pkg.name != "") {
  1723. pkgs += pkg;
  1724. }
  1725. }
  1726. foreach (unowned string pkgname in transaction.to_remove) {
  1727. AlpmPackage pkg = transaction.get_installed_pkg (pkgname);
  1728. if (pkg.name != "") {
  1729. pkgs += pkg;
  1730. }
  1731. }
  1732. populate_packages_list (pkgs);
  1733. #if DISABLE_AUR
  1734. #else
  1735. if (transaction.to_build.length != 0) {
  1736. packages_stackswitcher.visible = true;
  1737. AURPackage[] aur_pkgs = {};
  1738. foreach (unowned string pkgname in transaction.to_build) {
  1739. transaction.get_aur_details.begin (pkgname, (obj, res) => {
  1740. AURPackageDetails details_pkg = transaction.get_aur_details.end (res);
  1741. if (details_pkg.name != "") {
  1742. var aur_pkg = AURPackage () {
  1743. name = details_pkg.name,
  1744. version = details_pkg.version,
  1745. desc = details_pkg.desc,
  1746. popularity = details_pkg.popularity
  1747. };
  1748. aur_pkgs += aur_pkg;
  1749. populate_aur_list (aur_pkgs);
  1750. if (aur_pkgs.length > 0 ) {
  1751. if (pkgs.length == 0) {
  1752. packages_stack.visible_child_name = "aur";
  1753. } else {
  1754. var attention_val = GLib.Value (typeof (bool));
  1755. attention_val.set_boolean (true);
  1756. packages_stack.child_set_property (packages_stack.get_child_by_name ("aur"),
  1757. "needs-attention",
  1758. attention_val);
  1759. }
  1760. }
  1761. }
  1762. });
  1763. }
  1764. }
  1765. #endif
  1766. }
  1767. }
  1768. }
  1769. [GtkCallback]
  1770. void on_repos_treeview_selection_changed () {
  1771. Gtk.TreeIter iter;
  1772. Gtk.TreeSelection selection = repos_treeview.get_selection ();
  1773. if (selection.get_selected (null, out iter)) {
  1774. this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
  1775. string repo;
  1776. repos_list.get (iter, 0, out repo);
  1777. transaction.get_repo_pkgs.begin (repo, (obj, res) => {
  1778. populate_packages_list (transaction.get_repo_pkgs.end (res));
  1779. });
  1780. }
  1781. }
  1782. void on_main_stack_visible_child_changed () {
  1783. switch (main_stack.visible_child_name) {
  1784. case "browse":
  1785. button_back.visible = false;
  1786. filters_stackswitcher.visible = true;
  1787. details_button.sensitive = true;
  1788. break;
  1789. case "details":
  1790. button_back.visible = true;
  1791. filters_stackswitcher.visible = false;
  1792. details_button.sensitive = true;
  1793. break;
  1794. case "term":
  1795. filters_stackswitcher.visible = false;
  1796. button_back.visible = true;
  1797. details_button.get_style_context ().remove_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
  1798. details_button.sensitive = false;
  1799. break;
  1800. default:
  1801. break;
  1802. }
  1803. }
  1804. void on_filters_stack_visible_child_changed () {
  1805. refresh_packages_list ();
  1806. }
  1807. #if ENABLE_HAMBURGER
  1808. void on_menu_button_toggled () {
  1809. preferences_button.sensitive = !(transaction_running || sysupgrade_running);
  1810. }
  1811. #endif
  1812. [GtkCallback]
  1813. void on_history_button_clicked () {
  1814. this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
  1815. while (Gtk.events_pending ()) {
  1816. Gtk.main_iteration ();
  1817. }
  1818. var file = GLib.File.new_for_path ("/var/log/pacman.log");
  1819. if (!file.query_exists ()) {
  1820. stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
  1821. } else {
  1822. StringBuilder text = new StringBuilder ();
  1823. try {
  1824. // Open file for reading and wrap returned FileInputStream into a
  1825. // DataInputStream, so we can read line by line
  1826. var dis = new DataInputStream (file.read ());
  1827. string line;
  1828. // Read lines until end of file (null) is reached
  1829. while ((line = dis.read_line ()) != null) {
  1830. // construct text in reverse order
  1831. text.prepend (line + "\n");
  1832. }
  1833. } catch (GLib.Error e) {
  1834. stderr.printf ("%s\n", e.message);
  1835. }
  1836. var history_dialog = new HistoryDialog (this);
  1837. history_dialog.textview.buffer.set_text (text.str, (int) text.len);
  1838. this.get_window ().set_cursor (null);
  1839. history_dialog.show ();
  1840. history_dialog.response.connect (() => {
  1841. history_dialog.destroy ();
  1842. });
  1843. while (Gtk.events_pending ()) {
  1844. Gtk.main_iteration ();
  1845. }
  1846. }
  1847. }
  1848. [GtkCallback]
  1849. void on_local_button_clicked () {
  1850. Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog (
  1851. dgettext (null, "Install Local Packages"), this, Gtk.FileChooserAction.OPEN,
  1852. dgettext (null, "_Cancel"), Gtk.ResponseType.CANCEL,
  1853. dgettext (null, "_Open"),Gtk.ResponseType.ACCEPT);
  1854. chooser.window_position = Gtk.WindowPosition.CENTER_ON_PARENT;
  1855. chooser.icon_name = "system-software-install";
  1856. chooser.select_multiple = true;
  1857. chooser.local_only = false;
  1858. chooser.create_folders = false;
  1859. Gtk.FileFilter package_filter = new Gtk.FileFilter ();
  1860. package_filter.set_filter_name (dgettext (null, "Alpm Package"));
  1861. package_filter.add_pattern ("*.pkg.tar.xz");
  1862. chooser.add_filter (package_filter);
  1863. if (chooser.run () == Gtk.ResponseType.ACCEPT) {
  1864. SList<string> packages_paths = chooser.get_filenames ();
  1865. if (packages_paths.length () != 0) {
  1866. foreach (unowned string path in packages_paths) {
  1867. transaction.to_load.add (path);
  1868. }
  1869. chooser.destroy ();
  1870. try_lock_and_run (run_transaction);
  1871. }
  1872. } else {
  1873. chooser.destroy ();
  1874. while (Gtk.events_pending ()) {
  1875. Gtk.main_iteration ();
  1876. }
  1877. }
  1878. }
  1879. [GtkCallback]
  1880. void on_preferences_button_clicked () {
  1881. if (transaction.get_lock ()) {
  1882. this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
  1883. transaction.run_preferences_dialog ();
  1884. } else {
  1885. transaction.display_error (dgettext (null, "Waiting for another package manager to quit"), {});
  1886. }
  1887. }
  1888. void on_run_preferences_dialog_finished () {
  1889. transaction.unlock ();
  1890. if (filters_stack.visible_child_name == "updates") {
  1891. transaction.start_get_updates ();
  1892. } else {
  1893. this.get_window ().set_cursor (null);
  1894. }
  1895. }
  1896. [GtkCallback]
  1897. void on_about_button_clicked () {
  1898. Gtk.show_about_dialog (
  1899. this,
  1900. "program_name", "Pamac",
  1901. "icon_name", "system-software-install",
  1902. "logo_icon_name", "system-software-install",
  1903. "comments", dgettext (null, "A Gtk3 frontend for libalpm"),
  1904. "copyright", "Copyright © 2017-2019 Chris Cromer\nCopyright © 2017 Guillaume Benoit",
  1905. "version", VERSION,
  1906. "license_type", Gtk.License.GPL_3_0,
  1907. "website", "https://git.cromer.cl/cromer/pamac-classic");
  1908. }
  1909. [GtkCallback]
  1910. void on_details_button_clicked () {
  1911. important_details = false;
  1912. if (transaction_running || sysupgrade_running) {
  1913. main_stack.visible_child_name = "term";
  1914. } else {
  1915. #if DISABLE_AUR
  1916. uint total_pending = transaction.to_install.length + transaction.to_remove.length;
  1917. #else
  1918. uint total_pending = transaction.to_install.length + transaction.to_remove.length + transaction.to_build.length;
  1919. #endif
  1920. if (total_pending == 0) {
  1921. main_stack.visible_child_name = "term";
  1922. } else {
  1923. main_stack.visible_child_name = "browse";
  1924. filters_stack.notify["visible-child"].disconnect (on_filters_stack_visible_child_changed);
  1925. filters_stack.visible_child_name = "states";
  1926. filters_stack.notify["visible-child"].connect (on_filters_stack_visible_child_changed);
  1927. Gtk.TreeIter iter;
  1928. // show "Pending" in states_list
  1929. // "Pending" is at indice 4
  1930. states_list.get_iter (out iter, new Gtk.TreePath.from_indices (4));
  1931. Gtk.TreeSelection selection = states_treeview.get_selection ();
  1932. selection.changed.disconnect (on_states_treeview_selection_changed);
  1933. selection.select_iter (iter);
  1934. selection.changed.connect_after (on_states_treeview_selection_changed);
  1935. refresh_packages_list ();
  1936. }
  1937. }
  1938. }
  1939. [GtkCallback]
  1940. void on_apply_button_clicked () {
  1941. if (filters_stack.visible_child_name == "updates") {
  1942. force_refresh = false;
  1943. refreshing = true;
  1944. try_lock_and_run (run_refresh);
  1945. } else {
  1946. try_lock_and_run (run_transaction);
  1947. }
  1948. }
  1949. void run_transaction () {
  1950. transaction_running = true;
  1951. apply_button.sensitive = false;
  1952. cancel_button.sensitive = false;
  1953. transaction_infobox.show_all ();
  1954. transaction.run ();
  1955. }
  1956. void run_sysupgrade () {
  1957. sysupgrade_running = true;
  1958. apply_button.sensitive = false;
  1959. cancel_button.sensitive = false;
  1960. transaction.sysupgrade (false);
  1961. }
  1962. [GtkCallback]
  1963. void on_cancel_button_clicked () {
  1964. if (waiting) {
  1965. waiting = false;
  1966. transaction.stop_progressbar_pulse ();
  1967. transaction.to_load.remove_all ();
  1968. transaction.unlock ();
  1969. set_pendings_operations ();
  1970. } else if (transaction_running) {
  1971. transaction_running = false;
  1972. transaction.cancel ();
  1973. } else if (refreshing) {
  1974. refreshing = false;
  1975. transaction.cancel ();
  1976. } else if (sysupgrade_running) {
  1977. sysupgrade_running = false;
  1978. transaction.cancel ();
  1979. #if DISABLE_AUR
  1980. #else
  1981. transaction.to_build.remove_all ();
  1982. #endif
  1983. } else {
  1984. transaction.clear_lists ();
  1985. set_pendings_operations ();
  1986. refresh_packages_list ();
  1987. if (main_stack.visible_child_name == "details") {
  1988. if (transaction.get_installed_pkg (current_package_displayed).name != ""
  1989. || transaction.get_sync_pkg (current_package_displayed).name != "") {
  1990. display_package_properties (current_package_displayed);
  1991. #if DISABLE_AUR
  1992. #else
  1993. } else {
  1994. display_aur_properties (current_package_displayed);
  1995. #endif
  1996. }
  1997. }
  1998. while (Gtk.events_pending ()) {
  1999. Gtk.main_iteration ();
  2000. }
  2001. }
  2002. }
  2003. [GtkCallback]
  2004. void on_refresh_button_clicked () {
  2005. force_refresh = true;
  2006. try_lock_and_run (run_refresh);
  2007. }
  2008. void run_refresh () {
  2009. this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
  2010. apply_button.sensitive = false;
  2011. cancel_button.sensitive = true;
  2012. transaction_infobox.show_all ();
  2013. transaction.start_refresh (force_refresh);
  2014. }
  2015. void on_get_updates_finished (Updates updates) {
  2016. if (filters_stack.visible_child_name == "updates") {
  2017. transaction.to_update.remove_all ();
  2018. packages_stackswitcher.visible = false;
  2019. #if DISABLE_AUR
  2020. if ((updates.repos_updates.length) == 0) {
  2021. #else
  2022. if ((updates.repos_updates.length + updates.aur_updates.length) == 0) {
  2023. #endif
  2024. filters_stack.visible = false;
  2025. if (!refreshing && !transaction_running && !sysupgrade_running) {
  2026. transaction_infobox.visible = false;
  2027. }
  2028. packages_stack.visible_child_name = "updated";
  2029. this.get_window ().set_cursor (null);
  2030. } else {
  2031. if (updates.repos_updates.length > 0) {
  2032. foreach (unowned AlpmPackage pkg in updates.repos_updates) {
  2033. if (!transaction.temporary_ignorepkgs.contains (pkg.name)) {
  2034. transaction.to_update.add (pkg.name);
  2035. }
  2036. }
  2037. populate_packages_list (updates.repos_updates);
  2038. }
  2039. #if DISABLE_AUR
  2040. #else
  2041. if (updates.aur_updates.length > 0) {
  2042. packages_stackswitcher.visible = true;
  2043. foreach (unowned AURPackage pkg in updates.aur_updates) {
  2044. if (!transaction.temporary_ignorepkgs.contains (pkg.name)) {
  2045. transaction.to_update.add (pkg.name);
  2046. }
  2047. }
  2048. populate_aur_list (updates.aur_updates);
  2049. if (updates.repos_updates.length == 0) {
  2050. packages_stack.visible_child_name = "aur";
  2051. }
  2052. }
  2053. #endif
  2054. set_pendings_operations ();
  2055. }
  2056. }
  2057. #if DISABLE_AUR
  2058. else if ((updates.repos_updates.length) > 0) {
  2059. #else
  2060. else if ((updates.repos_updates.length + updates.aur_updates.length) > 0) {
  2061. #endif
  2062. this.get_window ().set_cursor (null);
  2063. var attention_val = GLib.Value (typeof (bool));
  2064. attention_val.set_boolean (true);
  2065. filters_stack.child_set_property (filters_stack.get_child_by_name ("updates"),
  2066. "needs-attention",
  2067. attention_val);
  2068. }
  2069. }
  2070. void on_start_downloading () {
  2071. cancel_button.sensitive = true;
  2072. }
  2073. void on_stop_downloading () {
  2074. cancel_button.sensitive = false;
  2075. }
  2076. #if DISABLE_AUR
  2077. #else
  2078. void on_start_building () {
  2079. cancel_button.sensitive = true;
  2080. }
  2081. void on_stop_building () {
  2082. cancel_button.sensitive = false;
  2083. }
  2084. #endif
  2085. void on_important_details_outpout (bool must_show) {
  2086. if (must_show) {
  2087. main_stack.visible_child_name = "term";
  2088. button_back.visible = false;
  2089. } else if (main_stack.visible_child_name != "term") {
  2090. important_details = true;
  2091. details_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
  2092. }
  2093. }
  2094. void on_generate_mirrors_list () {
  2095. generate_mirrors_list = true;
  2096. apply_button.sensitive = false;
  2097. transaction_infobox.show_all ();
  2098. }
  2099. void on_transaction_finished (bool success) {
  2100. transaction.refresh_handle ();
  2101. if (main_stack.visible_child_name == "details") {
  2102. if (transaction.get_installed_pkg (current_package_displayed).name != ""
  2103. || transaction.get_sync_pkg (current_package_displayed).name != "") {
  2104. display_package_properties (current_package_displayed);
  2105. #if DISABLE_AUR
  2106. #else
  2107. } else {
  2108. display_aur_properties (current_package_displayed);
  2109. #endif
  2110. }
  2111. } else if (main_stack.visible_child_name == "term") {
  2112. button_back.visible = true;
  2113. }
  2114. transaction.to_load.remove_all ();
  2115. if (refreshing) {
  2116. refreshing = false;
  2117. run_sysupgrade ();
  2118. } else if (sysupgrade_running) {
  2119. sysupgrade_running = false;
  2120. #if DISABLE_AUR
  2121. #else
  2122. transaction.to_build.remove_all ();
  2123. #endif
  2124. transaction.unlock ();
  2125. refresh_packages_list ();
  2126. } else {
  2127. transaction_running = false;
  2128. generate_mirrors_list = false;
  2129. transaction.unlock ();
  2130. refresh_packages_list ();
  2131. }
  2132. set_pendings_operations ();
  2133. }
  2134. }
  2135. }