Skip to content

Commit

Permalink
Merge pull request #32 from mfjurbala/add-package-description
Browse files Browse the repository at this point in the history
Feature #215 - Add package description
  • Loading branch information
ericbsd authored Jun 23, 2023
2 parents a7c7715 + d689488 commit 772d7f2
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 22 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
break
# Silence flake8, __VERSION__ is properly assigned below
else:
__VERSION__ = '1.5'
__VERSION__ = '1.7'

PROGRAM_VERSION = __VERSION__

Expand Down
74 changes: 59 additions & 15 deletions software-station
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ from software_station_pkg import (

from software_station_xpm import xpmPackageCategory

__VERSION__ = '1.6'
__VERSION__ = '1.7'

global pkg_to_install
pkg_to_install = []
Expand Down Expand Up @@ -98,23 +98,33 @@ class TableWindow(Gtk.Window):
self.nextbutton.set_sensitive(False)
toolbar.insert(self.nextbutton, 2)

self.desc_is_shown = False
self.desc_toggle = Gtk.ToggleToolButton()
self.desc_toggle.set_property("tooltip-text", _("Show Description"))
#self.desc_toggle.set_label(_("Show Description"))
self.desc_toggle.set_icon_name("view-list")
self.desc_toggle.connect("toggled", self.toggle_description)
self.desc_toggle.set_sensitive(True)
toolbar.insert(self.desc_toggle, 3)

self.available_toggle = Gtk.RadioToolButton(label=_("All Software"))
self.available_toggle.set_property("tooltip-text", _("All Software"))
self.available_toggle.set_icon_name("package_network")
self.available_or_installed = 'available'
self.available_toggle.connect("toggled", self.all_or_installed, "available")
self.available_toggle.set_sensitive(False)
toolbar.insert(self.available_toggle, 3)
toolbar.insert(self.available_toggle, 4)
self.installed_toggle = Gtk.RadioToolButton(label=_("Installed Software"), group=self.available_toggle)
self.installed_toggle.set_property("tooltip-text", _("Installed Software"))
self.installed_toggle.set_icon_name("system")
self.installed_toggle.connect("toggled", self.all_or_installed, "installed")
self.installed_toggle.set_sensitive(False)
toolbar.insert(self.installed_toggle, 4)
toolbar.insert(self.installed_toggle, 5)

separatortoolitem = Gtk.SeparatorToolItem()
toolbar.insert(separatortoolitem, 5)
toolbar.insert(separatortoolitem, 6)
toolitem = Gtk.ToolItem()
toolbar.insert(toolitem, 6)
toolbar.insert(toolitem, 7)
toolitem.set_expand(True)
self.search_entry = Gtk.Entry()
self.search_entry.set_icon_from_icon_name(Gtk.EntryIconPosition.PRIMARY, "search")
Expand Down Expand Up @@ -180,6 +190,20 @@ class TableWindow(Gtk.Window):
self.show_all()
self.initial_thread('initial')

def toggle_description(self, widget):
self.desc_is_shown = not self.desc_is_shown
if self.desc_is_shown:
self.table.remove(self.pkg_sw)
self.table.attach(self.pkg_sw, 2, 12, 0, 8)
self.table.attach(self.description_sw, 2, 12, 8, 12)
self.pkg_sw.show()
self.description_sw.show_all()
else:
self.table.remove(self.pkg_sw)
self.table.remove(self.description_sw)
self.table.attach(self.pkg_sw, 2, 12, 0, 12)
self.pkg_sw.show()

def cancel_change(self, widget):
global pkg_to_uninstall
global pkg_to_install
Expand Down Expand Up @@ -507,13 +531,15 @@ class TableWindow(Gtk.Window):
version = self.available_pkg['all'][pkg]['version']
size = self.available_pkg['all'][pkg]['size']
comment = self.available_pkg['all'][pkg]['comment']
description = self.available_pkg['all'][pkg]['description']
if pkg in pkg_to_install:
installed = True
elif pkg in pkg_to_uninstall:
installed = False
else:
installed = self.available_pkg['all'][pkg]['installed']
self.pkg_store.append([pixbuf, pkg, version, size, comment, installed])
self.pkg_store.append([pixbuf, pkg, version, size, comment,
installed, description])

def category_store_sync(self):
self.store.clear()
Expand Down Expand Up @@ -553,13 +579,15 @@ class TableWindow(Gtk.Window):
version = pkg_d[pkg]['version']
size = pkg_d[pkg]['size']
comment = pkg_d[pkg]['comment']
description = pkg_d[pkg]['description']
if pkg in pkg_to_install:
installed = True
elif pkg in pkg_to_uninstall:
installed = False
else:
installed = pkg_d[pkg]['installed']
self.pkg_store.append([pixbuf, pkg, version, size, comment, installed])
self.pkg_store.append([pixbuf, pkg, version, size, comment,
installed, description])

def add_and_rm_pkg(self, cell, path, model):
model[path][5] = not model[path][5]
Expand Down Expand Up @@ -609,10 +637,10 @@ class TableWindow(Gtk.Window):
category_sw.add(self.origin_treeview)
category_sw.show()

pkg_sw = Gtk.ScrolledWindow()
pkg_sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
pkg_sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.pkg_store = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, str, str, bool)
self.pkg_sw = Gtk.ScrolledWindow()
self.pkg_sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
self.pkg_sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.pkg_store = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, str, str, bool, str)
self.pkgtreeview = Gtk.TreeView()
self.pkgtreeview.set_model(self.pkg_store)
# self.pkgtreeview.connect_after("button_press_event",
Expand Down Expand Up @@ -654,18 +682,34 @@ class TableWindow(Gtk.Window):
comment_column.set_sort_column_id(4)
comment_column.set_resizable(True)
self.pkgtreeview.append_column(comment_column)
self.pkgtreeview.set_tooltip_column(4)
self.pkgtreeview.set_tooltip_column(6)

self.description_sw = Gtk.ScrolledWindow()
self.description_sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
self.description_sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
description_label = Gtk.Label(
label="Click on a package to show its detailed description.")
self.description_sw.add_with_viewport(description_label)

self.pkg_tree_selection = self.pkgtreeview.get_selection()
# self.pkg_tree_selection.set_mode(Gtk.SelectionMode.NONE)
# tree_selection.connect("clicked", self.selected_software)
self.pkgtreeview.set_sensitive(False)
pkg_sw.add(self.pkgtreeview)
pkg_sw.show()
self.pkg_tree_selection.connect("changed", self.on_selection_changed,
self.description_sw, description_label)
self.pkg_sw.add(self.pkgtreeview)
self.pkg_sw.show()
self.table.attach(category_sw, 0, 2, 0, 12)
self.table.attach(pkg_sw, 2, 12, 0, 12)
self.table.attach(self.pkg_sw, 2, 12, 0, 12)
self.show()
return self.table

def on_selection_changed(self, selection, description_sw, description_label):
model, treeiter = selection.get_selected()
if treeiter is not None:
description_label.set_text(model[treeiter][6])
self.description_sw.show_all()

def hidewindow(self, widget):
self.confirm_window.hide()
self.cancel_change(None)
Expand Down
17 changes: 11 additions & 6 deletions software_station_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,15 @@ def available_package_origin():
lst.sort()
return lst

# The pkg descriptions contain new lines, :, ::, etc so the delimiters
# <EOS> (end of section) and <EOL> (end of line) avoid collisions. These new
# lines also prevent the use of .splitlines, thus the normal split method.

def available_package_list():
cmd = "pkg rquery '%o:%n:%v:%sh:%c'"
cmd = "pkg rquery '%o<EOS>%n<EOS>%v<EOS>%sh<EOS>%c<EOS>%e<EOL>'"
pkg_out = Popen(cmd, shell=True, stdout=PIPE, close_fds=True,
universal_newlines=True, encoding='utf-8')
lst = list(set(pkg_out.stdout.read().splitlines()))
lst = list(filter(None, set(pkg_out.stdout.read().split('<EOL>\n'))))
lst.sort()
return lst

Expand All @@ -98,10 +101,10 @@ def installed_package_origin():


def installed_package_list():
cmd = "pkg query '%o:%n:%v:%sh:%c'"
cmd = "pkg query '%o<EOS>%n<EOS>%v<EOS>%sh<EOS>%c<EOS>%e<EOL>'"
pkg_out = Popen(cmd, shell=True, stdout=PIPE, close_fds=True,
universal_newlines=True, encoding='utf-8')
lst = list(set(pkg_out.stdout.read().splitlines()))
lst = list(filter(None, set(pkg_out.stdout.read().split('<EOL>\n'))))
lst.sort()
return lst

Expand All @@ -118,14 +121,15 @@ def available_package_dictionary(origin_list):
boolean = True
else:
boolean = False
pi = pkg.split(':')
pi = pkg.split('<EOS>')
pl = pi[0].split('/')
pkg_info = {
'origin': pi[0],
'name': pi[1],
'version': pi[2],
'size': pi[3],
'comment': pi[4],
'description': pi[5],
'installed': boolean
}
pkg_dict[pl[0]].update({pi[1]: pkg_info})
Expand All @@ -140,14 +144,15 @@ def installed_package_dictionary(origin_list):
for origin in origin_list:
pkg_dict[origin] = {}
for pkg in pkg_list:
pi = pkg.split(':')
pi = pkg.split('<EOS>')
pl = pi[0].split('/')
pkg_info = {
'origin': pi[0],
'name': pi[1],
'version': pi[2],
'size': pi[3],
'comment': pi[4],
'description': pi[5],
'installed': True
}
pkg_dict[pl[0]].update({pi[1]: pkg_info})
Expand Down

0 comments on commit 772d7f2

Please sign in to comment.