forked from cromer/pamac-classic
another step to master the world
This commit is contained in:
parent
5741cf9f5e
commit
0adb27f955
10
data/applications/pamac-tray.desktop
Normal file
10
data/applications/pamac-tray.desktop
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=Pamac Tray Icon
|
||||||
|
Icon=update-notifier
|
||||||
|
Exec=pamac-tray
|
||||||
|
Terminal=false
|
||||||
|
Type=Application
|
||||||
|
Categories=GNOME;GTK;System;
|
||||||
|
NoDisplay=True
|
||||||
|
StartupNotify=true
|
||||||
|
|
@ -125,7 +125,7 @@
|
|||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="top_label">
|
<object class="GtkLabel" id="sum_top_label">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="label" translatable="yes">label</property>
|
<property name="label" translatable="yes">label</property>
|
||||||
@ -194,7 +194,7 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="bottom_label">
|
<object class="GtkLabel" id="sum_bottom_label">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="label" translatable="yes">label</property>
|
<property name="label" translatable="yes">label</property>
|
||||||
@ -252,7 +252,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkWindow" id="MainWindow">
|
<object class="GtkWindow" id="ManagerWindow">
|
||||||
<property name="width_request">800</property>
|
<property name="width_request">800</property>
|
||||||
<property name="height_request">500</property>
|
<property name="height_request">500</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
@ -260,7 +260,7 @@
|
|||||||
<property name="default_width">800</property>
|
<property name="default_width">800</property>
|
||||||
<property name="default_height">500</property>
|
<property name="default_height">500</property>
|
||||||
<property name="icon">/usr/share/pamac/icons/22x22/status/package-sources.png</property>
|
<property name="icon">/usr/share/pamac/icons/22x22/status/package-sources.png</property>
|
||||||
<signal name="delete-event" handler="on_MainWindow_delete_event" swapped="no"/>
|
<signal name="delete-event" handler="on_ManagerWindow_delete_event" swapped="no"/>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="box1">
|
<object class="GtkBox" id="box1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -533,13 +533,13 @@
|
|||||||
<property name="homogeneous">True</property>
|
<property name="homogeneous">True</property>
|
||||||
<property name="layout_style">end</property>
|
<property name="layout_style">end</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="RefreshButton">
|
<object class="GtkButton" id="ManagerRefreshButton">
|
||||||
<property name="label">gtk-refresh</property>
|
<property name="label">gtk-refresh</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<signal name="clicked" handler="on_RefreshButton_clicked" swapped="no"/>
|
<signal name="clicked" handler="on_Manager_RefreshButton_clicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -548,13 +548,13 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="ValidButton">
|
<object class="GtkButton" id="ManagerValidButton">
|
||||||
<property name="label">gtk-apply</property>
|
<property name="label">gtk-apply</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<signal name="clicked" handler="on_ValidButton_clicked" swapped="no"/>
|
<signal name="clicked" handler="on_Manager_ValidButton_clicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -563,13 +563,13 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="EraseButton">
|
<object class="GtkButton" id="ManagerEraseButton">
|
||||||
<property name="label">gtk-undo</property>
|
<property name="label">gtk-undo</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<signal name="clicked" handler="on_EraseButton_clicked" swapped="no"/>
|
<signal name="clicked" handler="on_Manager_EraseButton_clicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -578,13 +578,13 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="QuitButton">
|
<object class="GtkButton" id="ManagerQuitButton">
|
||||||
<property name="label">gtk-quit</property>
|
<property name="label">gtk-quit</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<signal name="clicked" handler="on_QuitButton_clicked" swapped="no"/>
|
<signal name="clicked" handler="on_Manager_QuitButton_clicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
@ -1,157 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<!-- interface-requires gtk+ 3.0 -->
|
<!-- interface-requires gtk+ 3.0 -->
|
||||||
<object class="GtkWindow" id="ConfDialog">
|
<object class="GtkWindow" id="UpdaterWindow">
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="title" translatable="yes"> </property>
|
|
||||||
<property name="modal">True</property>
|
|
||||||
<property name="window_position">center-on-parent</property>
|
|
||||||
<property name="default_width">350</property>
|
|
||||||
<property name="default_height">250</property>
|
|
||||||
<property name="icon">/usr/share/pamac/icons/22x22/status/package-info.png</property>
|
|
||||||
<property name="type_hint">dialog</property>
|
|
||||||
<property name="skip_taskbar_hint">True</property>
|
|
||||||
<property name="urgency_hint">True</property>
|
|
||||||
<property name="deletable">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkBox" id="box7">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="top_label">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="label" translatable="yes">label</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkScrolledWindow" id="scrolledwindow4">
|
|
||||||
<property name="width_request">200</property>
|
|
||||||
<property name="height_request">120</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="vexpand">True</property>
|
|
||||||
<property name="shadow_type">in</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkTreeView" id="treeview4">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="vexpand">True</property>
|
|
||||||
<property name="model">transaction_add</property>
|
|
||||||
<property name="headers_visible">False</property>
|
|
||||||
<property name="headers_clickable">False</property>
|
|
||||||
<property name="enable_search">False</property>
|
|
||||||
<property name="search_column">0</property>
|
|
||||||
<child internal-child="selection">
|
|
||||||
<object class="GtkTreeSelection" id="treeview-selection6"/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkTreeViewColumn" id="_action">
|
|
||||||
<property name="title" translatable="yes">column</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext5">
|
|
||||||
<property name="yalign">0</property>
|
|
||||||
<property name="weight">600</property>
|
|
||||||
</object>
|
|
||||||
<attributes>
|
|
||||||
<attribute name="text">0</attribute>
|
|
||||||
</attributes>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkTreeViewColumn" id="_packages">
|
|
||||||
<property name="title" translatable="yes">column</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext6"/>
|
|
||||||
<attributes>
|
|
||||||
<attribute name="text">1</attribute>
|
|
||||||
</attributes>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="bottom_label">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="label" translatable="yes">label</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButtonBox" id="buttonbox2">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="spacing">6</property>
|
|
||||||
<property name="homogeneous">True</property>
|
|
||||||
<property name="layout_style">end</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="TransCancelButton">
|
|
||||||
<property name="label">gtk-cancel</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<signal name="clicked" handler="on_TransCancelButton_clicked" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="TransValidButton">
|
|
||||||
<property name="label">gtk-ok</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<signal name="clicked" handler="on_TransValidButton_clicked" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<object class="GtkWindow" id="UpdateWindow">
|
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="title" translatable="yes">Update Manager</property>
|
<property name="title" translatable="yes">Update Manager</property>
|
||||||
<property name="window_position">center</property>
|
<property name="window_position">center</property>
|
||||||
<property name="icon">/usr/share/pamac/icons/22x22/status/package-update.png</property>
|
<property name="icon">/usr/share/pamac/icons/22x22/status/package-update.png</property>
|
||||||
<signal name="delete-event" handler="on_UpdateWindow_delete_event" swapped="no"/>
|
<signal name="delete-event" handler="on_UpdaterWindow_delete_event" swapped="no"/>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="box1">
|
<object class="GtkBox" id="box1">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
@ -166,13 +21,13 @@
|
|||||||
<property name="spacing">5</property>
|
<property name="spacing">5</property>
|
||||||
<property name="layout_style">end</property>
|
<property name="layout_style">end</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="RefreshButton">
|
<object class="GtkButton" id="UpdaterRefreshButton">
|
||||||
<property name="label">gtk-refresh</property>
|
<property name="label">gtk-refresh</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<signal name="clicked" handler="on_RefreshButton_clicked" swapped="no"/>
|
<signal name="clicked" handler="on_Updater_RefreshButton_clicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -181,13 +36,13 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="ApplyButton">
|
<object class="GtkButton" id="UpdaterApplyButton">
|
||||||
<property name="label">gtk-apply</property>
|
<property name="label">gtk-apply</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<signal name="clicked" handler="on_ApplyButton_clicked" swapped="no"/>
|
<signal name="clicked" handler="on_Updater_ApplyButton_clicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -196,13 +51,13 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="QuitButton">
|
<object class="GtkButton" id="UpdaterQuitButton">
|
||||||
<property name="label">gtk-quit</property>
|
<property name="label">gtk-quit</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<signal name="clicked" handler="on_QuitButton_clicked" swapped="no"/>
|
<signal name="clicked" handler="on_Updater_QuitButton_clicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /usr/bin/python
|
||||||
|
# -*-coding:utf-8 -*-
|
||||||
|
|
||||||
/usr/bin/python /usr/lib/python3.3/site-packages/pamac/manager.py
|
from pamac import main
|
||||||
|
|
||||||
|
main.main('manager')
|
||||||
|
72
pamac-tray
72
pamac-tray
@ -1,3 +1,71 @@
|
|||||||
#! /bin/sh
|
#! /usr/bin/python
|
||||||
|
# -*-coding:utf-8-*-
|
||||||
|
|
||||||
/usr/bin/python /usr/lib/python3.3/site-packages/pamac/tray.py
|
from gi.repository import Gtk
|
||||||
|
from subprocess import Popen
|
||||||
|
from pamac import transaction
|
||||||
|
|
||||||
|
class Tray:
|
||||||
|
def __init__(self, icon, info):
|
||||||
|
self.icon = icon
|
||||||
|
self.info = info
|
||||||
|
self.statusIcon = Gtk.StatusIcon()
|
||||||
|
self.statusIcon.set_from_file(icon)
|
||||||
|
self.statusIcon.set_visible(True)
|
||||||
|
self.statusIcon.set_tooltip_markup(info)
|
||||||
|
|
||||||
|
self.menu = Gtk.Menu()
|
||||||
|
self.menuItem = Gtk.ImageMenuItem('Check for updates')
|
||||||
|
self.menuItem.connect('activate', self.execute_update, self.statusIcon)
|
||||||
|
self.menu.append(self.menuItem)
|
||||||
|
self.menuItem = Gtk.ImageMenuItem('Run pamac')
|
||||||
|
self.menuItem.connect('activate', self.execute_manager, self.statusIcon)
|
||||||
|
self.menu.append(self.menuItem)
|
||||||
|
self.menuItem = Gtk.ImageMenuItem('Quit')
|
||||||
|
self.menuItem.connect('activate', self.quit_tray, self.statusIcon)
|
||||||
|
self.menu.append(self.menuItem)
|
||||||
|
|
||||||
|
self.statusIcon.connect('popup-menu', self.popup_menu_cb, self.menu)
|
||||||
|
self.statusIcon.set_visible(1)
|
||||||
|
|
||||||
|
def execute_update(self, widget, event, data = None):
|
||||||
|
Popen(['/usr/bin/pamac-updater'])
|
||||||
|
|
||||||
|
def execute_manager(self, widget, event, data = None):
|
||||||
|
Popen(['/usr/bin/pamac-manager'])
|
||||||
|
|
||||||
|
def quit_tray(self, widget, data = None):
|
||||||
|
Gtk.main_quit()
|
||||||
|
|
||||||
|
def popup_menu_cb(self, widget, button, time, data = None):
|
||||||
|
if button == 3:
|
||||||
|
if data:
|
||||||
|
data.show_all()
|
||||||
|
data.popup(None, None, Gtk.StatusIcon.position_menu, self.statusIcon, 3, time)
|
||||||
|
|
||||||
|
def handle_error(error):
|
||||||
|
print('error',error)
|
||||||
|
icon = '/usr/share/pamac/icons/24x24/status/update-enhancement.png'
|
||||||
|
info = ' No update available'
|
||||||
|
tray = Tray(icon, info)
|
||||||
|
transaction.StopDaemon()
|
||||||
|
|
||||||
|
def handle_reply(reply):
|
||||||
|
do_syncfirst, updates = transaction.get_updates()
|
||||||
|
if updates:
|
||||||
|
icon = '/usr/share/pamac/icons/24x24/status/update-normal.png'
|
||||||
|
info = str(len(updates))+' update(s) available'
|
||||||
|
else:
|
||||||
|
icon = '/usr/share/pamac/icons/24x24/status/update-enhancement.png'
|
||||||
|
info = ' No update available'
|
||||||
|
tray = Tray(icon, info)
|
||||||
|
transaction.StopDaemon()
|
||||||
|
|
||||||
|
def do_refresh():
|
||||||
|
"""Sync databases like pacman -Sy"""
|
||||||
|
transaction.get_handle()
|
||||||
|
transaction.Refresh(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
do_refresh()
|
||||||
|
Gtk.main()
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /usr/bin/python
|
||||||
|
# -*-coding:utf-8 -*-
|
||||||
|
|
||||||
/usr/bin/python /usr/lib/python3.3/site-packages/pamac/updater.py
|
from pamac import main
|
||||||
|
|
||||||
|
main.main('updater')
|
||||||
|
@ -18,3 +18,18 @@ def format_pkg_name(name):
|
|||||||
name = name[0:index]
|
name = name[0:index]
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
from os.path import isfile
|
||||||
|
from os import getpid, remove
|
||||||
|
|
||||||
|
pid_file = '/tmp/pamac.pid'
|
||||||
|
|
||||||
|
def pid_file_exists():
|
||||||
|
return isfile(pid_file)
|
||||||
|
|
||||||
|
def write_pid_file():
|
||||||
|
with open(pid_file, "w") as _file:
|
||||||
|
_file.write(str(getpid()))
|
||||||
|
|
||||||
|
def rm_pid_file():
|
||||||
|
if isfile(pid_file):
|
||||||
|
remove(pid_file)
|
||||||
|
@ -10,11 +10,19 @@ from time import strftime, localtime
|
|||||||
from pamac import config, common, transaction
|
from pamac import config, common, transaction
|
||||||
|
|
||||||
interface = Gtk.Builder()
|
interface = Gtk.Builder()
|
||||||
|
|
||||||
|
interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
||||||
|
ErrorDialog = interface.get_object('ErrorDialog')
|
||||||
|
WarningDialog = interface.get_object('WarningDialog')
|
||||||
|
QuestionDialog = interface.get_object('QuestionDialog')
|
||||||
|
ProgressWindow = interface.get_object('ProgressWindow')
|
||||||
|
progress_bar = interface.get_object('progressbar2')
|
||||||
|
progress_label = interface.get_object('progresslabel2')
|
||||||
|
action_icon = interface.get_object('action_icon')
|
||||||
|
ProgressCancelButton = interface.get_object('ProgressCancelButton')
|
||||||
|
|
||||||
interface.add_from_file('/usr/share/pamac/gui/manager.glade')
|
interface.add_from_file('/usr/share/pamac/gui/manager.glade')
|
||||||
#interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
ManagerWindow = interface.get_object("ManagerWindow")
|
||||||
|
|
||||||
MainWindow = interface.get_object("MainWindow")
|
|
||||||
|
|
||||||
packages_list = interface.get_object('packages_list')
|
packages_list = interface.get_object('packages_list')
|
||||||
groups_list = interface.get_object('groups_list')
|
groups_list = interface.get_object('groups_list')
|
||||||
package_desc = interface.get_object('package_desc')
|
package_desc = interface.get_object('package_desc')
|
||||||
@ -26,12 +34,17 @@ installed_column = interface.get_object('installed_column')
|
|||||||
name_column = interface.get_object('name_column')
|
name_column = interface.get_object('name_column')
|
||||||
ConfDialog = interface.get_object('ConfDialog')
|
ConfDialog = interface.get_object('ConfDialog')
|
||||||
transaction_sum = interface.get_object('transaction_sum')
|
transaction_sum = interface.get_object('transaction_sum')
|
||||||
top_label = interface.get_object('top_label')
|
sum_top_label = interface.get_object('sum_top_label')
|
||||||
bottom_label = interface.get_object('bottom_label')
|
sum_bottom_label = interface.get_object('sum_bottom_label')
|
||||||
ChooseDialog = interface.get_object('ChooseDialog')
|
ChooseDialog = interface.get_object('ChooseDialog')
|
||||||
choose_list = interface.get_object('choose_list')
|
choose_list = interface.get_object('choose_list')
|
||||||
choose_label = interface.get_object('choose_label')
|
choose_label = interface.get_object('choose_label')
|
||||||
|
|
||||||
|
interface.add_from_file('/usr/share/pamac/gui/updater.glade')
|
||||||
|
UpdaterWindow = interface.get_object("UpdaterWindow")
|
||||||
|
update_listore = interface.get_object('update_list')
|
||||||
|
update_label = interface.get_object('update_label')
|
||||||
|
|
||||||
installed_column.set_sort_column_id(1)
|
installed_column.set_sort_column_id(1)
|
||||||
name_column.set_sort_column_id(0)
|
name_column.set_sort_column_id(0)
|
||||||
|
|
||||||
@ -52,6 +65,7 @@ list_dict = None
|
|||||||
current_group = None
|
current_group = None
|
||||||
transaction_type = None
|
transaction_type = None
|
||||||
transaction_dict = {}
|
transaction_dict = {}
|
||||||
|
mode = None
|
||||||
|
|
||||||
def set_list_dict_search(*patterns):
|
def set_list_dict_search(*patterns):
|
||||||
global pkg_name_list
|
global pkg_name_list
|
||||||
@ -201,7 +215,7 @@ def set_transaction_sum():
|
|||||||
while i < len(transaction.to_remove):
|
while i < len(transaction.to_remove):
|
||||||
transaction_sum.append([' ', transaction.to_remove[i]])
|
transaction_sum.append([' ', transaction.to_remove[i]])
|
||||||
i += 1
|
i += 1
|
||||||
bottom_label.set_markup('')
|
sum_bottom_label.set_markup('')
|
||||||
if transaction.to_add:
|
if transaction.to_add:
|
||||||
installed = []
|
installed = []
|
||||||
for pkg_object in config.pacman_conf.initialize_alpm().get_localdb().pkgcache:
|
for pkg_object in config.pacman_conf.initialize_alpm().get_localdb().pkgcache:
|
||||||
@ -216,20 +230,23 @@ def set_transaction_sum():
|
|||||||
while i < len(transaction.to_add):
|
while i < len(transaction.to_add):
|
||||||
transaction_sum.append([' ', transaction.to_add[i]])
|
transaction_sum.append([' ', transaction.to_add[i]])
|
||||||
i += 1
|
i += 1
|
||||||
|
if mode == 'manager':
|
||||||
if transaction.to_update:
|
if transaction.to_update:
|
||||||
transaction_sum.append(['To update:', transaction.to_update[0]])
|
transaction_sum.append(['To update:', transaction.to_update[0]])
|
||||||
i = 1
|
i = 1
|
||||||
while i < len(transaction.to_update):
|
while i < len(transaction.to_update):
|
||||||
transaction_sum.append([' ', transaction.to_update[i]])
|
transaction_sum.append([' ', transaction.to_update[i]])
|
||||||
i += 1
|
i += 1
|
||||||
bottom_label.set_markup('')
|
sum_bottom_label.set_markup('')
|
||||||
#bottom_label.set_markup('<b>Total Download size: </b>'+common.format_size(totaldlcb))
|
#sum_bottom_label.set_markup('<b>Total Download size: </b>'+common.format_size(totaldlcb))
|
||||||
top_label.set_markup('<big><b>Transaction Summary</b></big>')
|
sum_top_label.set_markup('<big><b>Transaction Summary</b></big>')
|
||||||
|
|
||||||
def handle_error(error):
|
def handle_error(error):
|
||||||
global transaction_type
|
global transaction_type
|
||||||
global transaction_dict
|
global transaction_dict
|
||||||
|
if error:
|
||||||
if not 'DBus.Error.NoReply' in str(error):
|
if not 'DBus.Error.NoReply' in str(error):
|
||||||
|
print('error',error)
|
||||||
transaction.ErrorDialog.format_secondary_text('Error:\n'+str(error))
|
transaction.ErrorDialog.format_secondary_text('Error:\n'+str(error))
|
||||||
response = transaction.ErrorDialog.run()
|
response = transaction.ErrorDialog.run()
|
||||||
if response:
|
if response:
|
||||||
@ -237,18 +254,21 @@ def handle_error(error):
|
|||||||
transaction.t_lock = False
|
transaction.t_lock = False
|
||||||
transaction.Release()
|
transaction.Release()
|
||||||
transaction.ProgressWindow.hide()
|
transaction.ProgressWindow.hide()
|
||||||
|
if mode == 'manager':
|
||||||
transaction.to_add = []
|
transaction.to_add = []
|
||||||
transaction.to_remove = []
|
transaction.to_remove = []
|
||||||
transaction_dict.clear()
|
transaction_dict.clear()
|
||||||
transaction_type = None
|
transaction_type = None
|
||||||
transaction.get_handle()
|
transaction.get_handle()
|
||||||
set_packages_list()
|
set_packages_list()
|
||||||
|
if mode == 'updater':
|
||||||
|
have_updates()
|
||||||
print('error',error)
|
print('error',error)
|
||||||
|
|
||||||
def handle_reply(reply):
|
def handle_reply(reply):
|
||||||
global transaction_type
|
global transaction_type
|
||||||
global transaction_dict
|
global transaction_dict
|
||||||
if str(reply):
|
if reply:
|
||||||
transaction.ErrorDialog.format_secondary_text('Error:\n'+str(reply))
|
transaction.ErrorDialog.format_secondary_text('Error:\n'+str(reply))
|
||||||
response = transaction.ErrorDialog.run()
|
response = transaction.ErrorDialog.run()
|
||||||
if response:
|
if response:
|
||||||
@ -265,9 +285,9 @@ def handle_reply(reply):
|
|||||||
set_packages_list()
|
set_packages_list()
|
||||||
else:
|
else:
|
||||||
transaction_type = None
|
transaction_type = None
|
||||||
do_syncfirst, updates = transaction.get_updates()
|
if have_updates():
|
||||||
if updates:
|
if mode == 'manager':
|
||||||
do_sysupgrade(do_syncfirst, updates)
|
do_sysupgrade()
|
||||||
|
|
||||||
def do_refresh():
|
def do_refresh():
|
||||||
"""Sync databases like pacman -Sy"""
|
"""Sync databases like pacman -Sy"""
|
||||||
@ -280,7 +300,22 @@ def do_refresh():
|
|||||||
Gtk.main_iteration()
|
Gtk.main_iteration()
|
||||||
transaction.Refresh(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
transaction.Refresh(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
||||||
|
|
||||||
def do_sysupgrade(do_syncfirst, updates_list):
|
def have_updates():
|
||||||
|
do_syncfirst, updates = transaction.get_updates()
|
||||||
|
update_listore.clear()
|
||||||
|
update_label.set_justify(Gtk.Justification.CENTER)
|
||||||
|
if not updates:
|
||||||
|
update_listore.append(["", ""])
|
||||||
|
update_label.set_markup("<big><b>No update available</b></big>")
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
for pkg in updates:
|
||||||
|
pkgname = pkg.name+" "+pkg.version
|
||||||
|
update_listore.append([pkgname, common.format_size(pkg.size)])
|
||||||
|
update_label.set_markup("<big><b>Available updates</b></big>")
|
||||||
|
return True
|
||||||
|
|
||||||
|
def do_sysupgrade():
|
||||||
global transaction_type
|
global transaction_type
|
||||||
"""Upgrade a system like pacman -Su"""
|
"""Upgrade a system like pacman -Su"""
|
||||||
if transaction.t_lock is False:
|
if transaction.t_lock is False:
|
||||||
@ -290,7 +325,7 @@ def do_sysupgrade(do_syncfirst, updates_list):
|
|||||||
transaction.to_add = []
|
transaction.to_add = []
|
||||||
transaction.to_remove = []
|
transaction.to_remove = []
|
||||||
check_conflicts(updates)
|
check_conflicts(updates)
|
||||||
if do_syncfirst is True:
|
if do_syncfirst:
|
||||||
for pkg in updates:
|
for pkg in updates:
|
||||||
transaction.to_add.append(pkg.name)
|
transaction.to_add.append(pkg.name)
|
||||||
if transaction.init_transaction(recurse = True):
|
if transaction.init_transaction(recurse = True):
|
||||||
@ -305,6 +340,12 @@ def do_sysupgrade(do_syncfirst, updates_list):
|
|||||||
transaction.get_to_remove()
|
transaction.get_to_remove()
|
||||||
transaction.get_to_add()
|
transaction.get_to_add()
|
||||||
set_transaction_sum()
|
set_transaction_sum()
|
||||||
|
if mode == 'updater':
|
||||||
|
if len(transaction.to_add) + len(transaction.to_remove) != 0:
|
||||||
|
ConfDialog.show_all()
|
||||||
|
else:
|
||||||
|
finalize()
|
||||||
|
if mode == 'manager':
|
||||||
ConfDialog.show_all()
|
ConfDialog.show_all()
|
||||||
else:
|
else:
|
||||||
if transaction.init_transaction(noconflicts = True):
|
if transaction.init_transaction(noconflicts = True):
|
||||||
@ -323,12 +364,24 @@ def do_sysupgrade(do_syncfirst, updates_list):
|
|||||||
transaction.get_to_remove()
|
transaction.get_to_remove()
|
||||||
transaction.get_to_add()
|
transaction.get_to_add()
|
||||||
set_transaction_sum()
|
set_transaction_sum()
|
||||||
|
if mode == 'updater':
|
||||||
|
if len(transaction.to_add) + len(transaction.to_remove) != 0:
|
||||||
|
ConfDialog.show_all()
|
||||||
|
else:
|
||||||
|
finalize()
|
||||||
|
if mode == 'manager':
|
||||||
ConfDialog.show_all()
|
ConfDialog.show_all()
|
||||||
|
|
||||||
|
def finalize():
|
||||||
|
transaction.progress_label.set_text('Preparing...')
|
||||||
|
transaction.action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/setup.png')
|
||||||
|
transaction.progress_bar.set_text('')
|
||||||
|
transaction.ProgressWindow.show_all()
|
||||||
|
while Gtk.events_pending():
|
||||||
|
Gtk.main_iteration()
|
||||||
|
transaction.Commit(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
||||||
|
|
||||||
def check_conflicts(pkg_list):
|
def check_conflicts(pkg_list):
|
||||||
#~ global to_add
|
|
||||||
#~ global to_remove
|
|
||||||
#~ global to_provide
|
|
||||||
depends = [pkg_list]
|
depends = [pkg_list]
|
||||||
warning = ''
|
warning = ''
|
||||||
#transaction.get_handle()
|
#transaction.get_handle()
|
||||||
@ -424,7 +477,8 @@ def check_conflicts(pkg_list):
|
|||||||
provide = pyalpm.find_satisfier(transaction.localpkgs.values(), replace)
|
provide = pyalpm.find_satisfier(transaction.localpkgs.values(), replace)
|
||||||
if provide:
|
if provide:
|
||||||
if provide.name != pkg.name:
|
if provide.name != pkg.name:
|
||||||
if not provide.name in transaction.localpkgs.keys():
|
if not pkg.name in transaction.localpkgs.keys():
|
||||||
|
if common.format_pkg_name(replace) in transaction.localpkgs.keys():
|
||||||
if not provide.name in transaction.to_remove:
|
if not provide.name in transaction.to_remove:
|
||||||
transaction.to_remove.append(provide.name)
|
transaction.to_remove.append(provide.name)
|
||||||
if warning:
|
if warning:
|
||||||
@ -459,21 +513,18 @@ def choose_provides(name):
|
|||||||
return [provides[pkgname] for pkgname in transaction.to_provide]
|
return [provides[pkgname] for pkgname in transaction.to_provide]
|
||||||
|
|
||||||
class Handler:
|
class Handler:
|
||||||
def on_MainWindow_delete_event(self, *arg):
|
#Manager Handlers
|
||||||
|
def on_ManagerWindow_delete_event(self, *arg):
|
||||||
transaction.StopDaemon()
|
transaction.StopDaemon()
|
||||||
if __name__ == "__main__":
|
common.rm_pid_file()
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
else:
|
|
||||||
MainWindow.hide()
|
|
||||||
|
|
||||||
def on_QuitButton_clicked(self, *arg):
|
def on_Manager_QuitButton_clicked(self, *arg):
|
||||||
transaction.StopDaemon()
|
transaction.StopDaemon()
|
||||||
if __name__ == "__main__":
|
common.rm_pid_file()
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
else:
|
|
||||||
MainWindow.hide()
|
|
||||||
|
|
||||||
def on_ValidButton_clicked(self, *arg):
|
def on_Manager_ValidButton_clicked(self, *arg):
|
||||||
if not transaction_dict:
|
if not transaction_dict:
|
||||||
transaction.ErrorDialog.format_secondary_text("No package is selected")
|
transaction.ErrorDialog.format_secondary_text("No package is selected")
|
||||||
response = transaction.ErrorDialog.run()
|
response = transaction.ErrorDialog.run()
|
||||||
@ -522,7 +573,7 @@ class Handler:
|
|||||||
transaction.WarningDialog.hide()
|
transaction.WarningDialog.hide()
|
||||||
transaction.t_lock = False
|
transaction.t_lock = False
|
||||||
|
|
||||||
def on_EraseButton_clicked(self, *arg):
|
def on_Manager_EraseButton_clicked(self, *arg):
|
||||||
global transaction_type
|
global transaction_type
|
||||||
global transaction_dict
|
global transaction_dict
|
||||||
transaction_dict.clear()
|
transaction_dict.clear()
|
||||||
@ -530,7 +581,7 @@ class Handler:
|
|||||||
transaction_type = None
|
transaction_type = None
|
||||||
refresh_packages_list()
|
refresh_packages_list()
|
||||||
|
|
||||||
def on_RefreshButton_clicked(self, *arg):
|
def on_Manager_RefreshButton_clicked(self, *arg):
|
||||||
do_refresh()
|
do_refresh()
|
||||||
set_packages_list()
|
set_packages_list()
|
||||||
|
|
||||||
@ -545,13 +596,7 @@ class Handler:
|
|||||||
|
|
||||||
def on_TransValidButton_clicked(self, *arg):
|
def on_TransValidButton_clicked(self, *arg):
|
||||||
ConfDialog.hide()
|
ConfDialog.hide()
|
||||||
transaction.progress_label.set_text('Preparing...')
|
finalize()
|
||||||
transaction.action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/setup.png')
|
|
||||||
transaction.progress_bar.set_text('')
|
|
||||||
transaction.ProgressWindow.show_all()
|
|
||||||
while Gtk.events_pending():
|
|
||||||
Gtk.main_iteration()
|
|
||||||
transaction.Commit(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
|
||||||
|
|
||||||
def on_search_button_clicked(self, widget):
|
def on_search_button_clicked(self, widget):
|
||||||
global list_dict
|
global list_dict
|
||||||
@ -649,13 +694,46 @@ class Handler:
|
|||||||
transaction.to_provide.remove(choose_list[line][1])
|
transaction.to_provide.remove(choose_list[line][1])
|
||||||
line += 1
|
line += 1
|
||||||
|
|
||||||
def main():
|
#Updater Handlers
|
||||||
|
def on_UpdaterWindow_delete_event(self, *arg):
|
||||||
|
transaction.StopDaemon()
|
||||||
|
common.rm_pid_file()
|
||||||
|
Gtk.main_quit()
|
||||||
|
|
||||||
|
def on_Updater_QuitButton_clicked(self, *arg):
|
||||||
|
transaction.StopDaemon()
|
||||||
|
common.rm_pid_file()
|
||||||
|
Gtk.main_quit()
|
||||||
|
|
||||||
|
def on_Updater_ApplyButton_clicked(self, *arg):
|
||||||
|
do_sysupgrade()
|
||||||
|
|
||||||
|
def on_Updater_RefreshButton_clicked(self, *arg):
|
||||||
|
do_refresh()
|
||||||
|
|
||||||
|
def on_ProgressCancelButton_clicked(self, *arg):
|
||||||
|
transaction.t_lock = False
|
||||||
|
transaction.Release()
|
||||||
|
transaction.ProgressWindow.hide()
|
||||||
|
have_updates()
|
||||||
|
|
||||||
|
def main(_mode):
|
||||||
|
if common.pid_file_exists():
|
||||||
|
transaction.ErrorDialog.format_secondary_text('Another instance of Pamac is running')
|
||||||
|
response = transaction.ErrorDialog.run()
|
||||||
|
if response:
|
||||||
|
transaction.ErrorDialog.hide()
|
||||||
|
else:
|
||||||
|
common.write_pid_file()
|
||||||
|
global mode
|
||||||
|
mode = _mode
|
||||||
interface.connect_signals(Handler())
|
interface.connect_signals(Handler())
|
||||||
do_refresh()
|
do_refresh()
|
||||||
MainWindow.show_all()
|
if mode == 'manager':
|
||||||
|
ManagerWindow.show_all()
|
||||||
|
if mode == 'updater':
|
||||||
|
update_label.set_markup("<big><b>Available updates</b></big>")
|
||||||
|
UpdaterWindow.show_all()
|
||||||
while Gtk.events_pending():
|
while Gtk.events_pending():
|
||||||
Gtk.main_iteration()
|
Gtk.main_iteration()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
Gtk.main()
|
Gtk.main()
|
@ -74,9 +74,9 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
self.icon = '/usr/share/pamac/icons/24x24/status/package-search.png'
|
self.icon = '/usr/share/pamac/icons/24x24/status/package-search.png'
|
||||||
self.already_transferred = 0
|
self.already_transferred = 0
|
||||||
elif ID is 17:
|
elif ID is 17:
|
||||||
self.action = 'Checking signatures...'
|
self.action = 'Loading packages files...'
|
||||||
self.icon = '/usr/share/pamac/icons/24x24/status/package-search.png'
|
self.icon = '/usr/share/pamac/icons/24x24/status/package-search.png'
|
||||||
print('Checking signatures')
|
print('Loading packages files')
|
||||||
elif ID is 26:
|
elif ID is 26:
|
||||||
self.action = 'Configuring...'
|
self.action = 'Configuring...'
|
||||||
self.icon = '/usr/share/pamac/icons/24x24/status/setup.png'
|
self.icon = '/usr/share/pamac/icons/24x24/status/setup.png'
|
||||||
|
@ -10,18 +10,6 @@ from dbus.mainloop.glib import DBusGMainLoop
|
|||||||
|
|
||||||
from pamac import config, common
|
from pamac import config, common
|
||||||
|
|
||||||
interface = Gtk.Builder()
|
|
||||||
interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
|
||||||
|
|
||||||
ErrorDialog = interface.get_object('ErrorDialog')
|
|
||||||
WarningDialog = interface.get_object('WarningDialog')
|
|
||||||
QuestionDialog = interface.get_object('QuestionDialog')
|
|
||||||
ProgressWindow = interface.get_object('ProgressWindow')
|
|
||||||
progress_bar = interface.get_object('progressbar2')
|
|
||||||
progress_label = interface.get_object('progresslabel2')
|
|
||||||
action_icon = interface.get_object('action_icon')
|
|
||||||
ProgressCancelButton = interface.get_object('ProgressCancelButton')
|
|
||||||
|
|
||||||
t_lock = False
|
t_lock = False
|
||||||
to_remove = []
|
to_remove = []
|
||||||
to_add = []
|
to_add = []
|
||||||
@ -31,6 +19,18 @@ handle = None
|
|||||||
syncpkgs = OrderedDict()
|
syncpkgs = OrderedDict()
|
||||||
localpkgs = OrderedDict()
|
localpkgs = OrderedDict()
|
||||||
|
|
||||||
|
interface = Gtk.Builder()
|
||||||
|
|
||||||
|
interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
||||||
|
ErrorDialog = interface.get_object('ErrorDialog')
|
||||||
|
WarningDialog = interface.get_object('WarningDialog')
|
||||||
|
QuestionDialog = interface.get_object('QuestionDialog')
|
||||||
|
ProgressWindow = interface.get_object('ProgressWindow')
|
||||||
|
progress_bar = interface.get_object('progressbar2')
|
||||||
|
progress_label = interface.get_object('progresslabel2')
|
||||||
|
action_icon = interface.get_object('action_icon')
|
||||||
|
ProgressCancelButton = interface.get_object('ProgressCancelButton')
|
||||||
|
|
||||||
def get_handle():
|
def get_handle():
|
||||||
global handle
|
global handle
|
||||||
global syncpkgs
|
global syncpkgs
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
#! /usr/bin/python
|
|
||||||
# -*-coding:utf-8-*-
|
|
||||||
|
|
||||||
from gi.repository import Gtk
|
|
||||||
|
|
||||||
from pamac import transaction, updater, manager
|
|
||||||
|
|
||||||
already_manager = False
|
|
||||||
|
|
||||||
class Tray:
|
|
||||||
def __init__(self, icon, info):
|
|
||||||
self.icon = icon
|
|
||||||
self.info = info
|
|
||||||
self.statusIcon = Gtk.StatusIcon()
|
|
||||||
self.statusIcon.set_from_file(icon)
|
|
||||||
self.statusIcon.set_visible(True)
|
|
||||||
self.statusIcon.set_tooltip_markup(info)
|
|
||||||
|
|
||||||
self.menu = Gtk.Menu()
|
|
||||||
self.menuItem = Gtk.ImageMenuItem('Check for updates')
|
|
||||||
self.menuItem.connect('activate', self.execute_update, self.statusIcon)
|
|
||||||
self.menu.append(self.menuItem)
|
|
||||||
self.menuItem = Gtk.ImageMenuItem('Run pamac')
|
|
||||||
self.menuItem.connect('activate', self.execute_manager, self.statusIcon)
|
|
||||||
self.menu.append(self.menuItem)
|
|
||||||
self.menuItem = Gtk.ImageMenuItem(Gtk.STOCK_QUIT)
|
|
||||||
self.menuItem.connect('activate', self.quit_tray, self.statusIcon)
|
|
||||||
self.menu.append(self.menuItem)
|
|
||||||
|
|
||||||
self.statusIcon.connect('popup-menu', self.popup_menu_cb, self.menu)
|
|
||||||
self.statusIcon.set_visible(1)
|
|
||||||
|
|
||||||
def execute_update(self, widget, event, data = None):
|
|
||||||
updater.main()
|
|
||||||
|
|
||||||
def execute_manager(self, widget, event, data = None):
|
|
||||||
global already_manager
|
|
||||||
if already_manager:
|
|
||||||
manager.MainWindow.show_all()
|
|
||||||
print('show')
|
|
||||||
else:
|
|
||||||
manager.main()
|
|
||||||
already_manager = True
|
|
||||||
|
|
||||||
def quit_tray(self, widget, data = None):
|
|
||||||
Gtk.main_quit()
|
|
||||||
|
|
||||||
def popup_menu_cb(self, widget, button, time, data = None):
|
|
||||||
if button == 3:
|
|
||||||
if data:
|
|
||||||
data.show_all()
|
|
||||||
data.popup(None, None, Gtk.StatusIcon.position_menu, self.statusIcon, 3, time)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
updates = transaction.get_updates()
|
|
||||||
if updates:
|
|
||||||
icon = '/usr/share/pamac/icons/24x24/status/update-normal.png'
|
|
||||||
info = str(len(updates))+' update(s) available'
|
|
||||||
else:
|
|
||||||
icon = '/usr/share/pamac/icons/24x24/status/update-enhancement.png'
|
|
||||||
info = ' No update available'
|
|
||||||
tray = Tray(icon, info)
|
|
||||||
Gtk.main()
|
|
212
pamac/updater.py
212
pamac/updater.py
@ -1,212 +0,0 @@
|
|||||||
#! /usr/bin/python
|
|
||||||
# -*-coding:utf-8 -*-
|
|
||||||
|
|
||||||
from gi.repository import Gtk
|
|
||||||
|
|
||||||
from pamac import config, common, transaction
|
|
||||||
|
|
||||||
interface = Gtk.Builder()
|
|
||||||
interface.add_from_file('/usr/share/pamac/gui/updater.glade')
|
|
||||||
#interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
|
||||||
|
|
||||||
UpdateWindow = interface.get_object("UpdateWindow")
|
|
||||||
|
|
||||||
ConfDialog = interface.get_object('ConfDialog')
|
|
||||||
transaction_add = interface.get_object('transaction_add')
|
|
||||||
top_label = interface.get_object('top_label')
|
|
||||||
bottom_label = interface.get_object('bottom_label')
|
|
||||||
update_listore = interface.get_object('update_list')
|
|
||||||
update_label = interface.get_object('update_label')
|
|
||||||
|
|
||||||
def do_refresh():
|
|
||||||
"""Sync databases like pacman -Sy"""
|
|
||||||
transaction.get_handle()
|
|
||||||
if transaction.t_lock is False:
|
|
||||||
transaction.t_lock = True
|
|
||||||
transaction.progress_label.set_text('Refreshing...')
|
|
||||||
transaction.action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/refresh-cache.png')
|
|
||||||
transaction.ProgressWindow.show_all()
|
|
||||||
while Gtk.events_pending():
|
|
||||||
Gtk.main_iteration()
|
|
||||||
transaction.Refresh(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
|
||||||
|
|
||||||
def have_updates():
|
|
||||||
available_updates = transaction.get_updates()
|
|
||||||
update_listore.clear()
|
|
||||||
update_label.set_justify(Gtk.Justification.CENTER)
|
|
||||||
if not available_updates:
|
|
||||||
update_listore.append(["", ""])
|
|
||||||
update_label.set_markup("<big><b>No update available</b></big>")
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
for pkg in available_updates:
|
|
||||||
pkgname = pkg.name
|
|
||||||
newversion = transaction.get_new_version_available(pkgname)
|
|
||||||
pkgname = pkg.name+" "+newversion
|
|
||||||
update_listore.append([pkgname, common.format_size(pkg.size)])
|
|
||||||
update_label.set_markup("<big><b>Available updates</b></big>")
|
|
||||||
return True
|
|
||||||
|
|
||||||
def set_transaction_add():
|
|
||||||
transaction_add.clear()
|
|
||||||
if transaction.to_remove:
|
|
||||||
transaction_add.append(['To remove:', transaction.to_remove[0]])
|
|
||||||
i = 1
|
|
||||||
while i < len(transaction.to_remove):
|
|
||||||
transaction_add.append([' ', transaction.to_remove[i]])
|
|
||||||
i += 1
|
|
||||||
bottom_label.set_markup('')
|
|
||||||
if transaction.to_add:
|
|
||||||
installed_name = []
|
|
||||||
for pkg_object in transaction.handle.get_localdb().pkgcache:
|
|
||||||
installed_name.append(pkg_object.name)
|
|
||||||
transaction.to_update = sorted(set(installed_name).intersection(transaction.to_add))
|
|
||||||
to_remove_from_add_name = sorted(set(transaction.to_update).intersection(transaction.to_add))
|
|
||||||
for name in to_remove_from_add_name:
|
|
||||||
transaction.to_add.remove(name)
|
|
||||||
if transaction.to_add:
|
|
||||||
transaction_add.append(['To install:', transaction.to_add[0]])
|
|
||||||
i = 1
|
|
||||||
while i < len(transaction.to_add):
|
|
||||||
transaction_add.append([' ', transaction.to_add[i]])
|
|
||||||
i += 1
|
|
||||||
bottom_label.set_markup('')
|
|
||||||
#bottom_label.set_markup('<b>Total Download size: </b>'+format_size(totaldlcb))
|
|
||||||
top_label.set_markup('<big><b>Additionnal Transaction(s)</b></big>')
|
|
||||||
|
|
||||||
def do_sysupgrade():
|
|
||||||
"""Upgrade a system like pacman -Su"""
|
|
||||||
if transaction.t_lock is False:
|
|
||||||
if transaction.do_syncfirst is True:
|
|
||||||
if transaction.init_transaction(recurse = True):
|
|
||||||
for pkg in transaction.list_first:
|
|
||||||
transaction.Add(pkg.name)
|
|
||||||
transaction.get_to_remove()
|
|
||||||
transaction.get_to_add()
|
|
||||||
set_transaction_add()
|
|
||||||
if len(transaction.to_add) + len(transaction.to_remove) != 0:
|
|
||||||
ConfDialog.show_all()
|
|
||||||
else:
|
|
||||||
finalize()
|
|
||||||
else:
|
|
||||||
if transaction.init_transaction():
|
|
||||||
error = transaction.Sysupgrade()
|
|
||||||
if error:
|
|
||||||
transaction.ErrorDialog.format_secondary_text(error)
|
|
||||||
response = transaction.ErrorDialog.run()
|
|
||||||
if response:
|
|
||||||
transaction.ErrorDialog.hide()
|
|
||||||
transaction.Release()
|
|
||||||
transaction.t_lock = False
|
|
||||||
transaction.get_to_remove()
|
|
||||||
transaction.get_to_add()
|
|
||||||
transaction.check_conflicts()
|
|
||||||
transaction.Release()
|
|
||||||
if len(transaction.to_add) == 0:
|
|
||||||
transaction.t_lock = False
|
|
||||||
print("Nothing to update")
|
|
||||||
else:
|
|
||||||
if transaction.init_transaction(noconflicts = True):
|
|
||||||
for pkgname in transaction.to_update:
|
|
||||||
transaction.Add(pkgname)
|
|
||||||
for pkgname in transaction.to_add:
|
|
||||||
transaction.Add(pkgname)
|
|
||||||
for pkgname in transaction.to_remove:
|
|
||||||
transaction.Remove(pkgname)
|
|
||||||
set_transaction_add()
|
|
||||||
if len(transaction.to_add) + len(transaction.to_remove) != 0:
|
|
||||||
ConfDialog.show_all()
|
|
||||||
else:
|
|
||||||
finalize()
|
|
||||||
|
|
||||||
def finalize():
|
|
||||||
error = transaction.Prepare()
|
|
||||||
if error:
|
|
||||||
transaction.ErrorDialog.format_secondary_text(error)
|
|
||||||
response = transaction.ErrorDialog.run()
|
|
||||||
if response:
|
|
||||||
transaction.ErrorDialog.hide()
|
|
||||||
transaction.Release()
|
|
||||||
transaction.t_lock = False
|
|
||||||
else:
|
|
||||||
transaction.progress_label.set_text('Preparing...')
|
|
||||||
transaction.action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/setup.png')
|
|
||||||
transaction.ProgressWindow.show_all()
|
|
||||||
while Gtk.events_pending():
|
|
||||||
Gtk.main_iteration()
|
|
||||||
transaction.Commit(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
|
||||||
|
|
||||||
def handle_error(error):
|
|
||||||
if not 'DBus.Error.NoReply' in str(error):
|
|
||||||
transaction.ErrorDialog.format_secondary_text('Commit Error:\n'+str(error))
|
|
||||||
response = transaction.ErrorDialog.run()
|
|
||||||
if response:
|
|
||||||
transaction.ErrorDialog.hide()
|
|
||||||
transaction.t_lock = False
|
|
||||||
transaction.Release()
|
|
||||||
transaction.ProgressWindow.hide()
|
|
||||||
have_updates()
|
|
||||||
|
|
||||||
def handle_reply(reply):
|
|
||||||
if str(reply):
|
|
||||||
transaction.ErrorDialog.format_secondary_text('Commit Error:\n'+str(reply))
|
|
||||||
response = transaction.ErrorDialog.run()
|
|
||||||
if response:
|
|
||||||
transaction.ErrorDialog.hide()
|
|
||||||
if transaction.do_syncfirst is True:
|
|
||||||
transaction.do_syncfirst = False
|
|
||||||
transaction.list_first = []
|
|
||||||
transaction.t_lock = False
|
|
||||||
transaction.Release()
|
|
||||||
transaction.ProgressWindow.hide()
|
|
||||||
have_updates()
|
|
||||||
|
|
||||||
class Handler:
|
|
||||||
def on_UpdateWindow_delete_event(self, *arg):
|
|
||||||
transaction.StopDaemon()
|
|
||||||
if __name__ == "__main__":
|
|
||||||
Gtk.main_quit()
|
|
||||||
else:
|
|
||||||
UpdateWindow.hide()
|
|
||||||
|
|
||||||
def on_QuitButton_clicked(self, *arg):
|
|
||||||
transaction.StopDaemon()
|
|
||||||
if __name__ == "__main__":
|
|
||||||
Gtk.main_quit()
|
|
||||||
else:
|
|
||||||
UpdateWindow.hide()
|
|
||||||
|
|
||||||
def on_ApplyButton_clicked(self, *arg):
|
|
||||||
do_sysupgrade()
|
|
||||||
|
|
||||||
def on_RefreshButton_clicked(self, *arg):
|
|
||||||
transaction.do_refresh()
|
|
||||||
#have_updates()
|
|
||||||
|
|
||||||
def on_TransCancelButton_clicked(self, *arg):
|
|
||||||
ConfDialog.hide()
|
|
||||||
transaction.t_lock = False
|
|
||||||
transaction.Release()
|
|
||||||
|
|
||||||
def on_TransValidButton_clicked(self, *arg):
|
|
||||||
ConfDialog.hide()
|
|
||||||
finalize()
|
|
||||||
|
|
||||||
def on_ProgressCancelButton_clicked(self, *arg):
|
|
||||||
transaction.t_lock = False
|
|
||||||
transaction.Release()
|
|
||||||
transaction.ProgressWindow.hide()
|
|
||||||
have_updates()
|
|
||||||
|
|
||||||
def main():
|
|
||||||
do_refresh()
|
|
||||||
#have_updates()
|
|
||||||
update_label.set_markup("<big><b>Available updates</b></big>")
|
|
||||||
interface.connect_signals(Handler())
|
|
||||||
UpdateWindow.show_all()
|
|
||||||
while Gtk.events_pending():
|
|
||||||
Gtk.main_iteration()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
Gtk.main()
|
|
101
test.py
101
test.py
@ -1,101 +0,0 @@
|
|||||||
#! /usr/bin/python
|
|
||||||
# -*-coding:utf-8 -*-
|
|
||||||
|
|
||||||
import pyalpm
|
|
||||||
from pamac import config, common
|
|
||||||
from collections import OrderedDict
|
|
||||||
#~ syncpkgs = OrderedDict()
|
|
||||||
#~ localpkgs = OrderedDict()
|
|
||||||
#~ virtualdeps = {}
|
|
||||||
|
|
||||||
class MyOrderedDict(OrderedDict):
|
|
||||||
def keys(self):
|
|
||||||
return [i for i in self]
|
|
||||||
def values(self):
|
|
||||||
return [self[i] for i in self]
|
|
||||||
|
|
||||||
d=MyOrderedDict()
|
|
||||||
d['pear']=3
|
|
||||||
d['apple']=2
|
|
||||||
print(d.items())
|
|
||||||
|
|
||||||
#~ for repo in config.handle.get_syncdbs():
|
|
||||||
#~ for pkg in repo.pkgcache:
|
|
||||||
#~ if not pkg.name in syncpkgs.keys():
|
|
||||||
#~ syncpkgs[pkg.name] = pkg
|
|
||||||
#~ for pkg in config.handle.get_localdb().pkgcache:
|
|
||||||
#~ if not pkg.name in localpkgs.keys():
|
|
||||||
#~ localpkgs[pkg.name] = pkg
|
|
||||||
#~ for pkg in syncpkgs.values():
|
|
||||||
#~ for name in pkg.depends:
|
|
||||||
#~ if (not name in syncpkgs.keys()) and (not '>' in name) and (not '<' in name) and (not '=' in name):
|
|
||||||
#~ if 'module' in name:
|
|
||||||
#~ if not virtualdeps.__contains__(name):
|
|
||||||
#~ virtualdeps[name] = []
|
|
||||||
#~ virtualdeps.get(name).append(pkg.name)
|
|
||||||
|
|
||||||
#~ to_add = ['libreoffice-writer', 'anjuta']
|
|
||||||
#~ depends = [[syncpkgs['libreoffice-writer'],syncpkgs['anjuta']]]
|
|
||||||
#~ to_provide = []
|
|
||||||
#~ to_remove = []
|
|
||||||
#~ warning = ''
|
|
||||||
#~ i = 0
|
|
||||||
#~ while depends[i]:
|
|
||||||
#~ depends.append([])
|
|
||||||
#~ for pkg in depends[i]:
|
|
||||||
#~ for depend in pkg.depends:
|
|
||||||
#~ provide = pyalpm.find_satisfier(localpkgs.values(), depend)
|
|
||||||
#~ if provide:
|
|
||||||
#~ print(i,'local',provide)
|
|
||||||
#~ if provide.name != common.format_pkg_name(depend):
|
|
||||||
#~ if ('-module' in depend) or ('linux' in depend):
|
|
||||||
#~ to_provide.append(depend)
|
|
||||||
#~ else:
|
|
||||||
#~ provide = pyalpm.find_satisfier(syncpkgs.values(), depend)
|
|
||||||
#~ if provide:
|
|
||||||
#~ print(i,'sync',provide)
|
|
||||||
#~ if provide.name != common.format_pkg_name(depend):
|
|
||||||
#~ print(provide.name,common.format_pkg_name(depend))
|
|
||||||
#~ to_provide.append(depend)
|
|
||||||
#~ else:
|
|
||||||
#~ depends[i+1].append(provide)
|
|
||||||
#~ for replace in pkg.replaces:
|
|
||||||
#~ provide = pyalpm.find_satisfier(localpkgs.values(), replace)
|
|
||||||
#~ if provide:
|
|
||||||
#~ if not provide.name in to_remove:
|
|
||||||
#~ to_remove.append(provide.name)
|
|
||||||
#~ if warning:
|
|
||||||
#~ warning = warning+'\n'
|
|
||||||
#~ warning = warning+provide.name+' will be replaced by '+pkg.name
|
|
||||||
#~ for conflict in pkg.conflicts:
|
|
||||||
#~ provide = pyalpm.find_satisfier(localpkgs.values(), conflict)
|
|
||||||
#~ if provide:
|
|
||||||
#~ if not provide.name in to_remove:
|
|
||||||
#~ to_remove.append(provide.name)
|
|
||||||
#~ if warning:
|
|
||||||
#~ warning = warning+'\n'
|
|
||||||
#~ warning = warning+pkg.name+' conflicts with '+provide.name
|
|
||||||
#~ provide = pyalpm.find_satisfier(depends[0], conflict)
|
|
||||||
#~ if provide:
|
|
||||||
#~ if not common.format_pkg_name(conflict) in to_remove:
|
|
||||||
#~ if pkg.name in to_add and common.format_pkg_name(conflict) in to_add:
|
|
||||||
#~ to_add.remove(common.format_pkg_name(conflict))
|
|
||||||
#~ to_add.remove(pkg.name)
|
|
||||||
#~ if warning:
|
|
||||||
#~ warning = warning+'\n'
|
|
||||||
#~ warning = warning+pkg.name+' conflicts with '+common.format_pkg_name(conflict)+'\nNone of them will be installed'
|
|
||||||
#~ i = i + 1
|
|
||||||
#~ for pkg in localpkgs.values():
|
|
||||||
#~ for conflict in pkg.conflicts:
|
|
||||||
#~ provide = pyalpm.find_satisfier(depends[0], conflict)
|
|
||||||
#~ if provide:
|
|
||||||
#~ if not provide.name in to_remove:
|
|
||||||
#~ to_remove.append(pkg.name)
|
|
||||||
#~ if warning:
|
|
||||||
#~ warning = warning+'\n'
|
|
||||||
#~ warning = warning+provide.name+' conflicts with '+pkg.name
|
|
||||||
#~ print('depends:',depends)
|
|
||||||
#~ print('to provide:',to_provide)
|
|
||||||
#~ print('to add:',to_add)
|
|
||||||
#~ print('to remove:',to_remove)
|
|
||||||
#~ print(warning)
|
|
Loading…
Reference in New Issue
Block a user