1
by Michael Vogt
* initial revision (after accidently killing it) |
1 |
# dialog_edit.py.in - edit a existing repository
|
2 |
#
|
|
3 |
# Copyright (c) 2004 Canonical
|
|
4 |
#
|
|
5 |
# Author: Michael Vogt <mvo@debian.org>
|
|
6 |
#
|
|
7 |
# This program is free software; you can redistribute it and/or
|
|
8 |
# modify it under the terms of the GNU General Public License as
|
|
9 |
# published by the Free Software Foundation; either version 2 of the
|
|
10 |
# License, or (at your option) any later version.
|
|
11 |
#
|
|
12 |
# This program is distributed in the hope that it will be useful,
|
|
13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 |
# GNU General Public License for more details.
|
|
16 |
#
|
|
17 |
# You should have received a copy of the GNU General Public License
|
|
18 |
# along with this program; if not, write to the Free Software
|
|
19 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
20 |
# USA
|
|
21 |
||
22 |
import os |
|
23 |
import gobject |
|
24 |
import gtk |
|
25 |
import gtk.glade |
|
26 |
||
27 |
import aptsources |
|
28 |
||
29 |
class dialog_edit: |
|
30 |
def __init__(self,parent,sourceslist,source_entry): |
|
31 |
self.sourceslist = sourceslist |
|
32 |
self.source_entry = source_entry |
|
33 |
||
34 |
# gtk stuff
|
|
35 |
if os.path.exists("../data/gnome-software-properties.glade"): |
|
36 |
self.gladexml = gtk.glade.XML("../data/gnome-software-properties.glade") |
|
37 |
else: |
|
38 |
self.gladexml = gtk.glade.XML("@prefix@/share/update-manager/gnome-software-properties.glade") |
|
39 |
self.main = self.gladexml.get_widget("dialog_edit") |
|
40 |
self.main.set_transient_for(parent) |
|
41 |
||
42 |
# type
|
|
43 |
combo_type = self.gladexml.get_widget("combobox_type") |
|
44 |
if source_entry.type == "deb": |
|
45 |
combo_type.set_active(0) |
|
46 |
elif source_entry.type == "deb-src": |
|
47 |
combo_type.set_active(1) |
|
48 |
else: |
|
49 |
print "Error, unknown source type: '%s'" % source_enrty.type |
|
50 |
||
51 |
# uri
|
|
52 |
entry = self.gladexml.get_widget("entry_uri") |
|
53 |
entry.set_text(source_entry.uri) |
|
54 |
||
55 |
entry = self.gladexml.get_widget("entry_dist") |
|
56 |
entry.set_text(source_entry.dist) |
|
57 |
||
58 |
entry = self.gladexml.get_widget("entry_comps") |
|
59 |
comps = "" |
|
60 |
for c in source_entry.comps: |
|
61 |
if len(comps) > 0: |
|
62 |
comps = comps + " " + c |
|
63 |
else: |
|
64 |
comps = c |
|
65 |
entry.set_text(comps) |
|
66 |
||
67 |
entry = self.gladexml.get_widget("entry_comment") |
|
68 |
entry.set_text(source_entry.comment) |
|
69 |
||
70 |
def run(self): |
|
71 |
res = self.main.run() |
|
72 |
if res == gtk.RESPONSE_OK: |
|
73 |
# get values
|
|
74 |
combo_type = self.gladexml.get_widget("combobox_type") |
|
75 |
if combo_type.get_active() == 0: |
|
76 |
line = "deb" |
|
77 |
else: |
|
78 |
line = "deb-src" |
|
79 |
entry = self.gladexml.get_widget("entry_uri") |
|
80 |
line = line + " " + entry.get_text() |
|
81 |
||
82 |
entry = self.gladexml.get_widget("entry_dist") |
|
83 |
line = line + " " + entry.get_text() |
|
84 |
||
85 |
entry = self.gladexml.get_widget("entry_comps") |
|
86 |
line = line + " " + entry.get_text() |
|
87 |
||
88 |
entry = self.gladexml.get_widget("entry_comment") |
|
89 |
if entry.get_text() != "": |
|
90 |
line = line + " #" + entry.get_text() + "\n" |
|
91 |
else: |
|
92 |
line = line + "\n" |
|
93 |
||
94 |
# change repository
|
|
95 |
index = self.sourceslist.list.index(self.source_entry) |
|
96 |
self.sourceslist.list[index] = aptsources.SourceEntry(line) |
|
97 |
#self.sourceslist.add(self.selected.type,
|
|
98 |
# self.selected.uri,
|
|
99 |
# self.selected.dist,
|
|
100 |
# self.selected_comps)
|
|
101 |
self.main.hide() |
|
102 |
return res |