Split out DependencyManager's GTK+-related stuff
Again, we simply split the GTK+-related code to a new module in the gpodder.gtkui package.
This commit is contained in:
parent
965cecfa7f
commit
26dda59ad9
|
@ -0,0 +1,57 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# gPodder - A media aggregator and podcast client
|
||||
# Copyright (c) 2005-2009 Thomas Perl and the gPodder Team
|
||||
#
|
||||
# gPodder is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# gPodder is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# gpodder.gtkui.services - UI parts for the services module (2009-08-24)
|
||||
#
|
||||
|
||||
import gpodder
|
||||
|
||||
_ = gpodder.gettext
|
||||
|
||||
import gtk
|
||||
|
||||
class DependencyModel(gtk.ListStore):
|
||||
C_NAME, C_DESCRIPTION, C_AVAILABLE_TEXT, C_AVAILABLE, C_MISSING = range(5)
|
||||
|
||||
def __init__(self, depman):
|
||||
gtk.ListStore.__init__(self, str, str, str, bool, str)
|
||||
|
||||
for feature_name, description, modules, tools in depman.dependencies:
|
||||
modules_available, module_info = depman.modules_available(modules)
|
||||
tools_available, tool_info = depman.tools_available(tools)
|
||||
|
||||
available = modules_available and tools_available
|
||||
if available:
|
||||
available_str = _('Available')
|
||||
else:
|
||||
available_str = _('Missing dependencies')
|
||||
|
||||
missing_str = []
|
||||
for module in modules:
|
||||
if not module_info[module]:
|
||||
missing_str.append(_('Python module "%s" not installed') % module)
|
||||
for tool in tools:
|
||||
if not tool_info[tool]:
|
||||
missing_str.append(_('Command "%s" not installed') % tool)
|
||||
missing_str = '\n'.join(missing_str)
|
||||
|
||||
self.append((feature_name, description, available_str, available, missing_str))
|
||||
|
|
@ -97,6 +97,7 @@ from gpodder.gtkui.model import EpisodeListModel
|
|||
from gpodder.gtkui.opml import OpmlListModel
|
||||
from gpodder.gtkui.config import ConfigModel
|
||||
from gpodder.gtkui.download import DownloadStatusModel
|
||||
from gpodder.gtkui.services import DependencyModel
|
||||
|
||||
from gpodder.libgpodder import db
|
||||
from gpodder.libgpodder import gl
|
||||
|
@ -4821,7 +4822,7 @@ class gPodderDependencyManager(BuilderWidget):
|
|||
self.treeview_components.append_column(col_name)
|
||||
col_installed = gtk.TreeViewColumn(_('Status'), gtk.CellRendererText(), text=2)
|
||||
self.treeview_components.append_column(col_installed)
|
||||
self.treeview_components.set_model(services.dependency_manager.get_model())
|
||||
self.treeview_components.set_model(DependencyModel(services.dependency_manager))
|
||||
self.btn_about.set_sensitive(False)
|
||||
self.btn_install.set_sensitive(False)
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ from gpodder import resolver
|
|||
from gpodder import download
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
import threading
|
||||
import time
|
||||
|
@ -119,31 +118,6 @@ class DependencyManager(object):
|
|||
|
||||
return (all_available, result)
|
||||
|
||||
def get_model(self):
|
||||
# Name, Description, Available (str), Available (bool), Missing (str)
|
||||
model = gtk.ListStore(str, str, str, bool, str)
|
||||
for feature_name, description, modules, tools in self.dependencies:
|
||||
modules_available, module_info = self.modules_available(modules)
|
||||
tools_available, tool_info = self.tools_available(tools)
|
||||
|
||||
available = modules_available and tools_available
|
||||
if available:
|
||||
available_str = _('Available')
|
||||
else:
|
||||
available_str = _('Missing dependencies')
|
||||
|
||||
missing_str = []
|
||||
for module in modules:
|
||||
if not module_info[module]:
|
||||
missing_str.append(_('Python module "%s" not installed') % module)
|
||||
for tool in tools:
|
||||
if not tool_info[tool]:
|
||||
missing_str.append(_('Command "%s" not installed') % tool)
|
||||
missing_str = '\n'.join(missing_str)
|
||||
|
||||
model.append([feature_name, description, available_str, available, missing_str])
|
||||
return model
|
||||
|
||||
|
||||
dependency_manager = DependencyManager()
|
||||
|
||||
|
|
Loading…
Reference in New Issue