big manager improvements

This commit is contained in:
guinux 2013-03-25 17:51:20 +01:00
parent 1bcbcc3c81
commit a2221d7605
4 changed files with 485 additions and 162 deletions

View File

@ -274,23 +274,20 @@
<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="GtkBox" id="box2"> <object class="GtkPaned" id="paned1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="margin_left">5</property>
<property name="vexpand">True</property> <property name="margin_right">5</property>
<child> <child>
<object class="GtkBox" id="box3"> <object class="GtkNotebook" id="notebook1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkBox" id="box4"> <object class="GtkBox" id="box2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_bottom">3</property> <property name="orientation">vertical</property>
<property name="spacing">5</property>
<child> <child>
<object class="GtkEntry" id="search_entry"> <object class="GtkEntry" id="search_entry">
<property name="visible">True</property> <property name="visible">True</property>
@ -299,6 +296,7 @@
<property name="is_focus">True</property> <property name="is_focus">True</property>
<property name="invisible_char">•</property> <property name="invisible_char">•</property>
<property name="width_chars">25</property> <property name="width_chars">25</property>
<property name="invisible_char_set">True</property>
<property name="primary_icon_stock">gtk-find</property> <property name="primary_icon_stock">gtk-find</property>
<signal name="activate" handler="on_search_entry_activate" swapped="no"/> <signal name="activate" handler="on_search_entry_activate" swapped="no"/>
<signal name="icon-press" handler="on_search_entry_icon_press" swapped="no"/> <signal name="icon-press" handler="on_search_entry_icon_press" swapped="no"/>
@ -306,51 +304,82 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="padding">2</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="search_button"> <object class="GtkScrolledWindow" id="scrolledwindow3">
<property name="label">gtk-find</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="shadow_type">in</property>
<property name="use_stock">True</property> <child>
<signal name="clicked" handler="on_search_button_clicked" swapped="no"/> <object class="GtkTreeView" id="search_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">search_list</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="search_treeview_selection">
<property name="mode">browse</property>
<signal name="changed" handler="on_search_treeview_selection_changed" swapped="no"/>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="Terms">
<property name="title" translatable="yes">column</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext8"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
</object> </object>
</child>
<child type="tab">
<object class="GtkLabel" id="tab1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Search</property>
</object>
<packing> <packing>
<property name="expand">False</property> <property name="tab_fill">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkScrolledWindow" id="scrolledwindow3"> <object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
<object class="GtkTreeView" id="treeview1"> <object class="GtkTreeView" id="groups_treeview">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="model">groups_list</property> <property name="model">groups_list</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property> <property name="headers_clickable">False</property>
<property name="enable_search">False</property> <property name="enable_search">False</property>
<property name="search_column">0</property>
<child internal-child="selection"> <child internal-child="selection">
<object class="GtkTreeSelection" id="treeview1_selection"> <object class="GtkTreeSelection" id="groups_treeview_selection">
<signal name="changed" handler="on_treeview1_selection_changed" swapped="no"/> <property name="mode">browse</property>
<signal name="changed" handler="on_groups_treeview_selection_changed" swapped="no"/>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkTreeViewColumn" id="Groups"> <object class="GtkTreeViewColumn" id="Groups">
<property name="title" translatable="yes">Groups</property>
<child> <child>
<object class="GtkCellRendererText" id="cellrenderertext2"/> <object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes> <attributes>
@ -363,36 +392,134 @@
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="position">1</property>
<property name="fill">True</property> </packing>
</child>
<child type="tab">
<object class="GtkLabel" id="tab2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Groups</property>
</object>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="state_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">state_list</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="state_treeview_selection">
<property name="mode">browse</property>
<signal name="changed" handler="on_state_treeview_selection_changed" swapped="no"/>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="State">
<property name="title" translatable="yes">column</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext9"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child type="tab">
<object class="GtkLabel" id="tab3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">State</property>
</object>
<packing>
<property name="position">2</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow8">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="repos_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">repos_list</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="repos_treeview_selection">
<property name="mode">browse</property>
<signal name="changed" handler="on_repos_treeview_selection_changed" swapped="no"/>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="Repos">
<property name="title" translatable="yes">column</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext10"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="tab4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Repos</property>
</object>
<packing>
<property name="position">3</property>
<property name="tab_fill">False</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="resize">False</property>
<property name="fill">True</property> <property name="shrink">False</property>
<property name="padding">6</property>
<property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkBox" id="box6"> <object class="GtkPaned" id="paned2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">6</property>
<child> <child>
<object class="GtkScrolledWindow" id="scrolledwindow1"> <object class="GtkScrolledWindow" id="scrolledwindow6">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
<object class="GtkTreeView" id="treeview2"> <object class="GtkTreeView" id="list_treeview">
<property name="width_request">500</property> <property name="width_request">500</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
@ -404,8 +531,8 @@
<property name="search_column">0</property> <property name="search_column">0</property>
<property name="show_expanders">False</property> <property name="show_expanders">False</property>
<child internal-child="selection"> <child internal-child="selection">
<object class="GtkTreeSelection" id="treeview2_selection"> <object class="GtkTreeSelection" id="list_treeview_selection">
<signal name="changed" handler="on_treeview2_selection_changed" swapped="no"/> <signal name="changed" handler="on_list_treeview_selection_changed" swapped="no"/>
</object> </object>
</child> </child>
<child> <child>
@ -417,29 +544,37 @@
<signal name="clicked" handler="on_installed_column_clicked" swapped="no"/> <signal name="clicked" handler="on_installed_column_clicked" swapped="no"/>
<child> <child>
<object class="GtkCellRendererToggle" id="cellrenderertoggle1"> <object class="GtkCellRendererToggle" id="cellrenderertoggle1">
<property name="cell_background_gdk">#000000000000</property> <property name="xpad">15</property>
<property name="cell_background_rgba">rgba(0,0,0,0)</property> <property name="xalign">0</property>
<property name="xpad">2</property>
<property name="ypad">2</property>
<signal name="toggled" handler="on_cellrenderertoggle1_toggled" swapped="no"/> <signal name="toggled" handler="on_cellrenderertoggle1_toggled" swapped="no"/>
</object> </object>
<attributes> <attributes>
<attribute name="activatable">2</attribute> <attribute name="visible">2</attribute>
<attribute name="active">1</attribute> <attribute name="active">3</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererPixbuf" id="cellrendererpixbuf1">
<property name="xpad">15</property>
<property name="xalign">1</property>
</object>
<attributes>
<attribute name="pixbuf">4</attribute>
</attributes> </attributes>
</child> </child>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkTreeViewColumn" id="name_column"> <object class="GtkTreeViewColumn" id="name_column">
<property name="resizable">True</property>
<property name="sizing">autosize</property> <property name="sizing">autosize</property>
<property name="title" translatable="yes">Name</property> <property name="title" translatable="yes">Name</property>
<property name="clickable">True</property> <property name="clickable">True</property>
<property name="sort_indicator">True</property> <property name="sort_indicator">True</property>
<signal name="clicked" handler="on_name_column_clicked" swapped="no"/> <signal name="clicked" handler="on_name_column_clicked" swapped="no"/>
<child> <child>
<object class="GtkCellRendererText" id="cellrenderertext3"/> <object class="GtkCellRendererText" id="cellrenderertext3">
<property name="xalign">0</property>
</object>
<attributes> <attributes>
<attribute name="text">0</attribute> <attribute name="text">0</attribute>
</attributes> </attributes>
@ -450,20 +585,19 @@
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="resize">True</property>
<property name="fill">True</property> <property name="shrink">False</property>
<property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkScrolledWindow" id="scrolledwindow2"> <object class="GtkScrolledWindow" id="scrolledwindow7">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
<object class="GtkTreeView" id="treeview3"> <object class="GtkTreeView" id="details_treeview">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="model">package_desc</property> <property name="model">package_desc</property>
@ -471,10 +605,9 @@
<property name="headers_clickable">False</property> <property name="headers_clickable">False</property>
<property name="rules_hint">True</property> <property name="rules_hint">True</property>
<property name="enable_search">False</property> <property name="enable_search">False</property>
<property name="search_column">0</property>
<child internal-child="selection"> <child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection3"> <object class="GtkTreeSelection" id="details_treeview_selection"/>
<property name="mode">none</property>
</object>
</child> </child>
<child> <child>
<object class="GtkTreeViewColumn" id="infotype"> <object class="GtkTreeViewColumn" id="infotype">
@ -508,24 +641,21 @@
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="resize">True</property>
<property name="fill">True</property> <property name="shrink">False</property>
<property name="position">1</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="resize">True</property>
<property name="fill">True</property> <property name="shrink">False</property>
<property name="padding">6</property>
<property name="position">1</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="padding">6</property> <property name="padding">5</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
@ -760,18 +890,33 @@
<columns> <columns>
<!-- column-name name --> <!-- column-name name -->
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name is_installed --> <!-- column-name installed -->
<column type="gboolean"/> <column type="gboolean"/>
<!-- column-name visible --> <!-- column-name visible -->
<column type="gboolean"/> <column type="gboolean"/>
<!-- column-name active -->
<column type="gboolean"/>
<!-- column-name icon -->
<column type="GdkPixbuf"/>
</columns>
</object>
<object class="GtkListStore" id="repos_list">
<columns>
<!-- column-name name -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="search_list">
<columns>
<!-- column-name terms -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="state_list">
<columns>
<!-- column-name state -->
<column type="gchararray"/>
</columns> </columns>
<data>
<row>
<col id="0" translatable="yes"> </col>
<col id="1">False</col>
<col id="2">False</col>
</row>
</data>
</object> </object>
<object class="GtkListStore" id="transaction_sum"> <object class="GtkListStore" id="transaction_sum">
<columns> <columns>

View File

@ -2,7 +2,7 @@
# -*-coding:utf-8-*- # -*-coding:utf-8-*-
from gi.repository import Gtk, GObject from gi.repository import Gtk, GObject
from subprocess import call from subprocess import Popen
from pamac import common, transaction from pamac import common, transaction
import dbus import dbus
import threading import threading
@ -37,10 +37,10 @@ class Tray:
self.statusIcon.connect('activate', self.activate_cb, self.menu) self.statusIcon.connect('activate', self.activate_cb, self.menu)
def execute_update(self, widget, event, data = None): def execute_update(self, widget, event, data = None):
call(['/usr/bin/pamac-updater']) Popen(['/usr/bin/pamac-updater'])
def execute_manager(self, widget, event, data = None): def execute_manager(self, widget, event, data = None):
call(['/usr/bin/pamac-manager']) Popen(['/usr/bin/pamac-manager'])
def quit_tray(self, widget, data = None): def quit_tray(self, widget, data = None):
t.shutdown() t.shutdown()
@ -53,7 +53,7 @@ class Tray:
data.popup(None, None, Gtk.StatusIcon.position_menu, self.statusIcon, 3, time) data.popup(None, None, Gtk.StatusIcon.position_menu, self.statusIcon, 3, time)
def activate_cb(self, widget, data = None): def activate_cb(self, widget, data = None):
call(['notify-send', '-i', icon, '-u', 'normal', 'Pamac', info]) Popen(['notify-send', '-i', icon, '-u', 'normal', 'Pamac', info])
def update_icon(self, icon, info): def update_icon(self, icon, info):
self.statusIcon.set_from_file(icon) self.statusIcon.set_from_file(icon)
@ -83,7 +83,7 @@ class PeriodicTask(threading.Thread):
self._finished.wait(self._interval) self._finished.wait(self._interval)
def task(self): def task(self):
call(['/usr/bin/pamac-refresh']) Popen(['/usr/bin/pamac-refresh'])
def set_icon(updates): def set_icon(updates):
global icon global icon
@ -91,7 +91,7 @@ def set_icon(updates):
if updates: if updates:
icon = update_icon icon = update_icon
info = update_info.format(updates) info = update_info.format(updates)
call(['notify-send', '-i', icon, '-u', 'normal', 'Pamac', info]) Popen(['notify-send', '-i', icon, '-u', 'normal', 'Pamac', info])
else: else:
icon = noupdate_icon icon = noupdate_icon
info = noupdate_info info = noupdate_info

View File

@ -2,7 +2,7 @@
# -*-coding:utf-8 -*- # -*-coding:utf-8 -*-
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository.GdkPixbuf import Pixbuf
import pyalpm import pyalpm
import dbus import dbus
from collections import OrderedDict from collections import OrderedDict
@ -20,15 +20,21 @@ interface = Gtk.Builder()
interface.add_from_file('/usr/share/pamac/gui/manager.glade') interface.add_from_file('/usr/share/pamac/gui/manager.glade')
ManagerWindow = interface.get_object("ManagerWindow") ManagerWindow = interface.get_object("ManagerWindow")
packages_list = interface.get_object('packages_list')
groups_list = interface.get_object('groups_list')
package_desc = interface.get_object('package_desc') package_desc = interface.get_object('package_desc')
toggle = interface.get_object('cellrenderertoggle1') #select_toggle = interface.get_object('cellrenderertoggle1')
search_entry = interface.get_object('search_entry') search_entry = interface.get_object('search_entry')
tree2 = interface.get_object('treeview2_selection') search_list = interface.get_object('search_list')
tree1 = interface.get_object('treeview1_selection') search_selection = interface.get_object('search_treeview_selection')
packages_list = interface.get_object('packages_list')
list_selection = interface.get_object('list_treeview_selection')
installed_column = interface.get_object('installed_column') installed_column = interface.get_object('installed_column')
name_column = interface.get_object('name_column') name_column = interface.get_object('name_column')
groups_list = interface.get_object('groups_list')
groups_selection = interface.get_object('groups_treeview_selection')
state_list = interface.get_object('state_list')
state_selection = interface.get_object('state_treeview_selection')
repos_list = interface.get_object('repos_list')
repos_selection = interface.get_object('repos_treeview_selection')
ConfDialog = interface.get_object('ConfDialog') ConfDialog = interface.get_object('ConfDialog')
transaction_sum = interface.get_object('transaction_sum') transaction_sum = interface.get_object('transaction_sum')
sum_top_label = interface.get_object('sum_top_label') sum_top_label = interface.get_object('sum_top_label')
@ -50,10 +56,10 @@ update_label = interface.get_object('update_label')
def action_signal_handler(action): def action_signal_handler(action):
if action: if action:
progress_label.set_text(action) progress_label.set_text(action)
if ('Refreshing' in action) or ('Preparing' in action) or ('Downloading' in action) or ('Checking' in action) or ('Resolving' in action) or ('Loading' in action): if ('Installing' in action) or ('Removing' in action) or ('Updating' in action):
ProgressCancelButton.set_visible(True)
else:
ProgressCancelButton.set_visible(False) ProgressCancelButton.set_visible(False)
else:
ProgressCancelButton.set_visible(True)
def icon_signal_handler(icon): def icon_signal_handler(icon):
action_icon.set_from_file(icon) action_icon.set_from_file(icon)
@ -76,14 +82,23 @@ bus.add_signal_receiver(percent_signal_handler, dbus_interface = "org.manjaro.pa
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)
installed_icon = Pixbuf.new_from_file('/usr/share/pamac/icons/22x22/status/package-installed.png')
uninstalled_icon = Pixbuf.new_from_file('/usr/share/pamac/icons/22x22/status/package-available.png')
to_install_icon = Pixbuf.new_from_file('/usr/share/pamac/icons/22x22/status/package-add.png')
to_remove_icon = Pixbuf.new_from_file('/usr/share/pamac/icons/22x22/status/package-delete.png')
locked_icon = Pixbuf.new_from_file('/usr/share/pamac/icons/22x22/status/package-blocked.png')
search_icon = Pixbuf.new_from_file('/usr/share/pamac/icons/22x22/status/package-search.png')
pkg_name_list = [] pkg_name_list = []
pkg_object_dict = {} pkg_object_dict = {}
pkg_installed_dict = {} pkg_installed_dict = {}
list_dict = None current_filter = (None, None)
current_group = None
transaction_type = None transaction_type = None
transaction_dict = {} transaction_dict = {}
mode = None mode = None
states = ['Installed', 'Uninstalled', 'Orphans', 'To install', 'To remove']
for state in states:
state_list.append([state])
def get_groups(): def get_groups():
tmp_list = [] tmp_list = []
@ -95,6 +110,11 @@ def get_groups():
for name in tmp_list: for name in tmp_list:
groups_list.append([name]) groups_list.append([name])
def get_repos():
for repo in transaction.handle.get_syncdbs():
repos_list.append([repo.name])
repos_list.append(['local'])
def set_list_dict_search(*patterns): def set_list_dict_search(*patterns):
global pkg_name_list global pkg_name_list
global pkg_object_dict global pkg_object_dict
@ -114,6 +134,17 @@ def set_list_dict_search(*patterns):
pkg_installed_dict[pkg_object.name] = True pkg_installed_dict[pkg_object.name] = True
pkg_object_dict[pkg_object.name] = pkg_object pkg_object_dict[pkg_object.name] = pkg_object
pkg_name_list = sorted(pkg_name_list) pkg_name_list = sorted(pkg_name_list)
if pkg_name_list:
joined = ''
for term in patterns:
joined += term
already_in_list = False
if len(search_list) != 0:
for line in search_list:
if joined == line[0]:
already_in_list = True
if not already_in_list:
search_list.append([joined])
def set_list_dict_group(group): def set_list_dict_group(group):
global pkg_name_list global pkg_name_list
@ -142,39 +173,153 @@ def set_list_dict_group(group):
pkg_object_dict[pkg_object.name] = pkg_object pkg_object_dict[pkg_object.name] = pkg_object
pkg_name_list = sorted(pkg_name_list) pkg_name_list = sorted(pkg_name_list)
def set_list_dict_installed():
global pkg_name_list
global pkg_object_dict
global pkg_installed_dict
pkg_name_list = []
pkg_object_dict = {}
pkg_installed_dict = {}
for pkg_object in transaction.localpkgs.values():
if not pkg_object.name in pkg_name_list:
pkg_name_list.append(pkg_object.name)
pkg_installed_dict[pkg_object.name] = True
pkg_object_dict[pkg_object.name] = pkg_object
def set_list_dict_uninstalled():
global pkg_name_list
global pkg_object_dict
global pkg_installed_dict
pkg_name_list = []
pkg_object_dict = {}
pkg_installed_dict = {}
for pkg_object in transaction.syncpkgs.values():
if not pkg_object.name in transaction.localpkgs.keys():
if not pkg_object.name in pkg_name_list:
pkg_name_list.append(pkg_object.name)
pkg_installed_dict[pkg_object.name] = False
pkg_object_dict[pkg_object.name] = pkg_object
def set_list_dict_local():
global pkg_name_list
global pkg_object_dict
global pkg_installed_dict
pkg_name_list = []
pkg_object_dict = {}
pkg_installed_dict = {}
for pkg_object in transaction.localpkgs.values():
if (not pkg_object.name in pkg_name_list) and (not pkg_object.name in transaction.syncpkgs.keys()):
pkg_name_list.append(pkg_object.name)
pkg_installed_dict[pkg_object.name] = True
pkg_object_dict[pkg_object.name] = pkg_object
def set_list_dict_orphans():
global pkg_name_list
global pkg_object_dict
global pkg_installed_dict
pkg_name_list = []
pkg_object_dict = {}
pkg_installed_dict = {}
for pkg_object in transaction.localpkgs.values():
if (pkg_object.reason == 1) and (not pkg_object.compute_requiredby()):
pkg_name_list.append(pkg_object.name)
pkg_installed_dict[pkg_object.name] = True
pkg_object_dict[pkg_object.name] = pkg_object
def set_list_dict_to_install():
global pkg_name_list
global pkg_object_dict
global pkg_installed_dict
pkg_name_list = []
pkg_object_dict = {}
pkg_installed_dict = {}
if transaction_type == "install":
for pkg_object in transaction_dict.values():
if not pkg_object.name in pkg_name_list:
pkg_name_list.append(pkg_object.name)
pkg_installed_dict[pkg_object.name] = False
pkg_object_dict[pkg_object.name] = pkg_object
def set_list_dict_to_remove():
global pkg_name_list
global pkg_object_dict
global pkg_installed_dict
pkg_name_list = []
pkg_object_dict = {}
pkg_installed_dict = {}
if transaction_type == "remove":
for pkg_object in transaction_dict.values():
if not pkg_object.name in pkg_name_list:
pkg_name_list.append(pkg_object.name)
pkg_installed_dict[pkg_object.name] = True
pkg_object_dict[pkg_object.name] = pkg_object
def set_list_dict_repos(repo):
global pkg_name_list
global pkg_object_dict
global pkg_installed_dict
pkg_name_list = []
pkg_object_dict = {}
pkg_installed_dict = {}
for db in transaction.handle.get_syncdbs():
if db.name == repo:
for pkg_object in db.pkgcache:
if not pkg_object.name in pkg_name_list:
pkg_name_list.append(pkg_object.name)
if pkg_object.name in transaction.localpkgs.keys():
pkg_installed_dict[pkg_object.name] = True
pkg_object_dict[pkg_object.name] = transaction.localpkgs[pkg_object.name]
else:
pkg_installed_dict[pkg_object.name] = False
pkg_object_dict[pkg_object.name] = pkg_object
def refresh_packages_list(): def refresh_packages_list():
global packages_list
packages_list.clear() packages_list.clear()
if not pkg_name_list: if not pkg_name_list:
packages_list.append(["No package found", False, False]) packages_list.append(["No package found", False, False, False, search_icon])
else: else:
for name in pkg_name_list: for name in pkg_name_list:
if name in config.holdpkg: if name in config.holdpkg:
packages_list.append([name, pkg_installed_dict[name], False]) packages_list.append([name, True, False, True, locked_icon])
elif transaction_type is "install": elif transaction_type is "install":
if pkg_installed_dict[name] is True: if pkg_installed_dict[name] is True:
packages_list.append([name, pkg_installed_dict[name], False]) packages_list.append([name, True, False, True, installed_icon])
elif name in transaction_dict.keys(): elif name in transaction_dict.keys():
packages_list.append([name, True, True]) packages_list.append([name, False, True, True, to_install_icon])
else: else:
packages_list.append([name, pkg_installed_dict[name], True]) packages_list.append([name, False, True, False, uninstalled_icon])
elif transaction_type is "remove": elif transaction_type is "remove":
if pkg_installed_dict[name] is False: if pkg_installed_dict[name] is False:
packages_list.append([name, pkg_installed_dict[name], False]) packages_list.append([name, False, False, False, uninstalled_icon])
elif name in transaction_dict.keys(): elif name in transaction_dict.keys():
packages_list.append([name, False, True]) packages_list.append([name, True, True, False, to_remove_icon])
else: else:
packages_list.append([name, pkg_installed_dict[name], True]) packages_list.append([name, True, True, True, installed_icon])
elif pkg_installed_dict[name] is True:
packages_list.append([name, True, True, True, installed_icon])
else: else:
packages_list.append([name, pkg_installed_dict[name], True]) packages_list.append([name, False, True, False, uninstalled_icon])
def set_packages_list(): def set_packages_list():
global list_dict if current_filter[0] == 'search':
if list_dict == "search": print(current_filter[1])
search_strings_list = search_entry.get_text().split() set_list_dict_search(*current_filter[1])
set_list_dict_search(*search_strings_list) if current_filter[0] == 'group':
if list_dict == "group": set_list_dict_group(current_filter[1])
set_list_dict_group(current_group) if current_filter[0] == 'installed':
set_list_dict_installed()
if current_filter[0] == 'uninstalled':
set_list_dict_uninstalled()
if current_filter[0] == 'orphans':
set_list_dict_orphans()
if current_filter[0] == 'local':
set_list_dict_local()
if current_filter[0] == 'to_install':
set_list_dict_to_install()
if current_filter[0] == 'to_remove':
set_list_dict_to_remove()
if current_filter[0] == 'repo':
set_list_dict_repos(current_filter[1])
refresh_packages_list() refresh_packages_list()
def set_desc(pkg, style): def set_desc(pkg, style):
@ -292,6 +437,7 @@ def handle_error(error):
transaction_dict.clear() transaction_dict.clear()
transaction_type = None transaction_type = None
transaction.update_db() transaction.update_db()
get_repos()
get_groups() get_groups()
set_packages_list() set_packages_list()
if mode == 'updater': if mode == 'updater':
@ -317,6 +463,7 @@ def handle_reply(reply):
transaction.to_remove = [] transaction.to_remove = []
transaction_dict.clear() transaction_dict.clear()
transaction.update_db() transaction.update_db()
get_repos()
get_groups() get_groups()
if (transaction_type == "install") or (transaction_type == "remove"): if (transaction_type == "install") or (transaction_type == "remove"):
transaction_type = None transaction_type = None
@ -491,7 +638,6 @@ def check_conflicts(mode, pkg_list):
already_provided = False already_provided = False
for pkgname in transaction.to_add: for pkgname in transaction.to_add:
_pkg = transaction.syncpkgs[pkgname] _pkg = transaction.syncpkgs[pkgname]
print('test',transaction.to_add)
provide = pyalpm.find_satisfier([_pkg], depend) provide = pyalpm.find_satisfier([_pkg], depend)
if provide: if provide:
already_provided = True already_provided = True
@ -517,23 +663,24 @@ def check_conflicts(mode, pkg_list):
provide = pyalpm.find_satisfier(transaction.localpkgs.values(), conflict) provide = pyalpm.find_satisfier(transaction.localpkgs.values(), conflict)
if provide: if provide:
if provide.name != pkg.name: if provide.name != pkg.name:
new_provide = pyalpm.find_satisfier([transaction.syncpkgs[provide.name]], conflict) if transaction.syncpkgs.__contains__(provide.name):
if new_provide: new_provide = pyalpm.find_satisfier([transaction.syncpkgs[provide.name]], conflict)
required = pkg.compute_requiredby() if new_provide:
if required: required = pkg.compute_requiredby()
str_required = '' if required:
for item in required: str_required = ''
if str_required: for item in required:
str_required += ', ' if str_required:
str_required += item str_required += ', '
if error: str_required += item
error += '\n' if error:
error += '{} conflicts with {} but cannot be removed because it is needed by {}'.format(provide.name, pkg.name, str_required) error += '\n'
elif not provide.name in transaction.to_remove: error += '{} conflicts with {} but cannot be removed because it is needed by {}'.format(provide.name, pkg.name, str_required)
transaction.to_remove.append(provide.name) elif not provide.name in transaction.to_remove:
if warning: transaction.to_remove.append(provide.name)
warning += '\n' if warning:
warning += pkg.name+' conflicts with '+provide.name warning += '\n'
warning += pkg.name+' conflicts with '+provide.name
provide = pyalpm.find_satisfier(depends[0], conflict) provide = pyalpm.find_satisfier(depends[0], conflict)
if provide: if provide:
if not common.format_pkg_name(conflict) == pkg.name: if not common.format_pkg_name(conflict) == pkg.name:
@ -550,23 +697,24 @@ def check_conflicts(mode, pkg_list):
provide = pyalpm.find_satisfier(depends[0], conflict) provide = pyalpm.find_satisfier(depends[0], conflict)
if provide: if provide:
if provide.name != pkg.name: if provide.name != pkg.name:
new_provide = pyalpm.find_satisfier([transaction.syncpkgs[pkg.name]], conflict) if transaction.syncpkgs.__contains__(pkg.name):
if new_provide: new_provide = pyalpm.find_satisfier([transaction.syncpkgs[pkg.name]], conflict)
required = pkg.compute_requiredby() if new_provide:
if required: required = pkg.compute_requiredby()
str_required = '' if required:
for item in required: str_required = ''
if str_required: for item in required:
str_required += ', ' if str_required:
str_required += item str_required += ', '
if error: str_required += item
error += '\n' if error:
error += '{} conflicts with {} but cannot be removed because it is needed by {}'.format(provide.name, pkg.name, str_required) error += '\n'
elif not provide.name in transaction.to_remove: error += '{} conflicts with {} but cannot be removed because it is needed by {}'.format(provide.name, pkg.name, str_required)
transaction.to_remove.append(pkg.name) elif not provide.name in transaction.to_remove:
if warning: transaction.to_remove.append(pkg.name)
warning += '\n' if warning:
warning += provide.name+' conflicts with '+pkg.name warning += '\n'
warning += provide.name+' conflicts with '+pkg.name
if mode == 'updating': if mode == 'updating':
for pkg in transaction.syncpkgs.values(): for pkg in transaction.syncpkgs.values():
for replace in pkg.replaces: for replace in pkg.replaces:
@ -684,7 +832,6 @@ class Handler:
def on_Manager_RefreshButton_clicked(self, *arg): def on_Manager_RefreshButton_clicked(self, *arg):
do_refresh() do_refresh()
#set_packages_list()
def on_TransCancelButton_clicked(self, *arg): def on_TransCancelButton_clicked(self, *arg):
global transaction_type global transaction_type
@ -699,23 +846,18 @@ class Handler:
ConfDialog.hide() ConfDialog.hide()
finalize() finalize()
def on_search_button_clicked(self, widget):
global list_dict
list_dict = "search"
set_packages_list()
def on_search_entry_icon_press(self, *arg): def on_search_entry_icon_press(self, *arg):
global list_dict global current_filter
list_dict = "search" current_filter = ('search', search_entry.get_text().split())
set_packages_list() set_packages_list()
def on_search_entry_activate(self, widget): def on_search_entry_activate(self, widget):
global list_dict global current_filter
list_dict = "search" current_filter = ('search', search_entry.get_text().split())
set_packages_list() set_packages_list()
def on_treeview2_selection_changed(self, widget): def on_list_treeview_selection_changed(self, widget):
liste, line = tree2.get_selected() liste, line = list_selection.get_selected()
if line is not None: if line is not None:
if packages_list[line][0] in pkg_object_dict.keys(): if packages_list[line][0] in pkg_object_dict.keys():
pkg_object = pkg_object_dict[packages_list[line][0]] pkg_object = pkg_object_dict[packages_list[line][0]]
@ -725,13 +867,44 @@ class Handler:
style = "sync" style = "sync"
set_desc(pkg_object, style) set_desc(pkg_object, style)
def on_treeview1_selection_changed(self, widget): def on_search_treeview_selection_changed(self, widget):
global list_dict global current_filter
global current_group liste, line = search_selection.get_selected()
liste, line = tree1.get_selected()
if line is not None: if line is not None:
list_dict = "group" current_filter = ('search', search_list[line][0].split())
current_group = groups_list[line][0] set_packages_list()
def on_groups_treeview_selection_changed(self, widget):
global current_filter
liste, line = groups_selection.get_selected()
if line is not None:
current_filter = ('group', groups_list[line][0])
set_packages_list()
def on_state_treeview_selection_changed(self, widget):
global current_filter
liste, line = state_selection.get_selected()
if line is not None:
if state_list[line][0] == 'Installed':
current_filter = ('installed', None)
if state_list[line][0] == 'Uninstalled':
current_filter = ('uninstalled', None)
if state_list[line][0] == 'Orphans':
current_filter = ('orphans', None)
if state_list[line][0] == 'To install':
current_filter = ('to_install', None)
if state_list[line][0] == 'To remove':
current_filter = ('to_remove', None)
set_packages_list()
def on_repos_treeview_selection_changed(self, widget):
global current_filter
liste, line = repos_selection.get_selected()
if line is not None:
if repos_list[line][0] == 'local':
current_filter = ('local', None)
else:
current_filter = ('repo', repos_list[line][0])
set_packages_list() set_packages_list()
def on_installed_column_clicked(self, widget): def on_installed_column_clicked(self, widget):
@ -745,6 +918,10 @@ class Handler:
global transaction_dict global transaction_dict
global pkg_object_dict global pkg_object_dict
if packages_list[line][0] in transaction_dict.keys(): if packages_list[line][0] in transaction_dict.keys():
if transaction_type == "remove":
packages_list[line][4] = installed_icon
if transaction_type == "install":
packages_list[line][4] = uninstalled_icon
transaction_dict.pop(packages_list[line][0]) transaction_dict.pop(packages_list[line][0])
if not transaction_dict: if not transaction_dict:
transaction_type = None transaction_type = None
@ -755,11 +932,11 @@ class Handler:
else: else:
packages_list[lin][2] = True packages_list[lin][2] = True
lin += 1 lin += 1
pass
else: else:
if packages_list[line][1] is True: if packages_list[line][1] is True:
transaction_type = "remove" transaction_type = "remove"
transaction_dict[packages_list[line][0]] = pkg_object_dict[packages_list[line][0]] transaction_dict[packages_list[line][0]] = pkg_object_dict[packages_list[line][0]]
packages_list[line][4] = to_remove_icon
lin = 0 lin = 0
while lin < len(packages_list): while lin < len(packages_list):
if not packages_list[lin][0] in transaction_dict.keys(): if not packages_list[lin][0] in transaction_dict.keys():
@ -769,13 +946,14 @@ class Handler:
if packages_list[line][1] is False: if packages_list[line][1] is False:
transaction_type = "install" transaction_type = "install"
transaction_dict[packages_list[line][0]] = pkg_object_dict[packages_list[line][0]] transaction_dict[packages_list[line][0]] = pkg_object_dict[packages_list[line][0]]
packages_list[line][4] = to_install_icon
lin = 0 lin = 0
while lin < len(packages_list): while lin < len(packages_list):
if not packages_list[lin][0] in transaction_dict.keys(): if not packages_list[lin][0] in transaction_dict.keys():
if packages_list[lin][1] is True: if packages_list[lin][1] is True:
packages_list[lin][2] = False packages_list[lin][2] = False
lin += 1 lin += 1
packages_list[line][1] = not packages_list[line][1] packages_list[line][3] = not packages_list[line][3]
packages_list[line][2] = True packages_list[line][2] = True
def on_cellrenderertoggle2_toggled(self, widget, line): def on_cellrenderertoggle2_toggled(self, widget, line):

View File

@ -29,7 +29,7 @@ InfoDialog = interface.get_object('InfoDialog')
def get_handle(): def get_handle():
global handle global handle
handle = config.pacman_conf.initialize_alpm() handle = config.handle()
print('get handle') print('get handle')
def update_db(): def update_db():