source: projects/pygtk-rpminstall/trunk/src/dependdialog.py @ 5069

Revision 5069, 2.0 KB checked in by yasumichi, 13 years ago (diff)

move ui and icons

Line 
1# dependdialog.py
2#
3# Copyright (C) 2011 - Yasumichi Akahoshi
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18from gi.repository import Gtk, GdkPixbuf, Gdk
19import os, sys, rpm
20
21UI_FILE = "ui/dependdialog.ui"
22
23class DependDialog:
24        def __init__(self, unresolved_dependencies):
25                self.builder = Gtk.Builder()
26                self.builder.add_from_file(os.path.join (os.path.dirname(__file__), UI_FILE))
27                self.builder.connect_signals(self)
28                self.build_depend_listview()
29                depend_liststore = self.builder.get_object('depend_liststore')
30                for tup in unresolved_dependencies:
31                        object_package = '-'.join(tup[0])
32                        depend_package = '-'.join(tup[1])
33                        if tup[3] == rpm.RPMDEP_SENSE_CONFLICTS:
34                                reason = _("Conflict")
35                        elif tup[3] == rpm.RPMDEP_SENSE_REQUIRES:
36                                reason = _("Requires")
37                        else:
38                                reason = _("Unknown")
39                        depend_liststore.append([object_package, depend_package, reason])
40
41        def build_depend_listview(self):
42                depend_listview = self.builder.get_object('depend_listview')
43                index = 0
44                for column_title in [_("Object Package"), _("Depend Package"), _("Reason")]:
45                        column_text = Gtk.TreeViewColumn(column_title)
46                        renderer_text = Gtk.CellRendererText()
47                        column_text.pack_start(renderer_text, True)
48                        column_text.add_attribute(renderer_text, "text", index)
49                        index += 1
50                        depend_listview.append_column(column_text)
51
52        def run(self):
53                self.dialog = self.builder.get_object('dialog1')
54                self.dialog.run()
55
56        def ok(self, widget):
57                self.dialog.destroy()
Note: See TracBrowser for help on using the repository browser.