3 # GPytage v0.2.0_beta2 released under the GPLv2 License
4 # GTK Utility to help manage Portage's user config files
6 ############################################################################
7 # Copyright (C) 2008 by Kenneth Prugh #
10 # This program is free software; you can redistribute it and#or modify #
11 # it under the terms of the GNU General Public License as published by #
12 # the Free Software Foundation under version 2 of the license. #
14 # This program is distributed in the hope that it will be useful, #
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17 # GNU General Public License for more details. #
19 # You should have received a copy of the GNU General Public License #
20 # along with this program; if not, write to the #
21 # Free Software Foundation, Inc., #
22 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
23 ############################################################################
25 import pygtk
; pygtk
.require("2.0")
29 from getopt
import getopt
, GetoptError
35 try: #load icons as pixbufs and set as default icon
37 self
.i16
= gtk
.gdk
.pixbuf_new_from_file(PIXMAPS
+ "gpytage-16x16.png")
38 self
.i24
= gtk
.gdk
.pixbuf_new_from_file(PIXMAPS
+ "gpytage-24x24.png")
39 self
.i32
= gtk
.gdk
.pixbuf_new_from_file(PIXMAPS
+ "gpytage-32x32.png")
40 self
.i48
= gtk
.gdk
.pixbuf_new_from_file(PIXMAPS
+ "gpytage-48x48.png")
41 self
.i64
= gtk
.gdk
.pixbuf_new_from_file(PIXMAPS
+ "gpytage-64x64.png")
42 self
.i128
= gtk
.gdk
.pixbuf_new_from_file(PIXMAPS
+ "gpytage-128x128.png")
43 gtk
.window_set_default_icon_list(self
.i16
, self
.i24
, self
.i32
, self
.i48
, self
.i64
, self
.i128
)
45 print "GPytage could not find its icons!"
48 self
.window
.set_default_size(645, 400)
50 self
.datastore
= datastore
51 self
.files
= config_files
54 create_treeiter() #populate the left panel
56 self
.uimanager
= gtk
.UIManager()
57 self
.accelgroup
= self
.uimanager
.get_accel_group()
58 self
.actiongroup
= gtk
.ActionGroup('GPytage')
61 <menubar name="MenuBar">
63 <menuitem action="New"/>
65 <menuitem action="Save"/>
67 <menuitem action="Quit"/>
70 <menuitem action="Revert"/>
72 <menuitem action="Add Package"/>
73 <menuitem action="Remove Package"/>
75 <menuitem action="Delete"/>
76 <menuitem action="Split"/>
77 <menuitem action="Rename"/>
80 <menuitem action="Expand All"/>
81 <menuitem action="Collapse All"/>
84 <menuitem action="About"/>
87 <toolbar name="ToolBar">
88 <toolitem action="New"/>
89 <toolitem action="Save"/>
90 <toolitem action="Revert"/>
91 <toolitem action="Add Package"/>
92 <toolitem action="Remove Package"/>
93 <toolitem action="Comment"/>
94 <toolitem action="Uncomment"/>
98 #This controls the menubar and the toolbar
99 self
.actiongroup
.add_actions([
100 ('Quit', gtk
.STOCK_QUIT
, '_Quit', None, 'Quit GPytage', self
.destroy
),
101 ('Revert', gtk
.STOCK_REVERT_TO_SAVED
, '_Revert', None, 'Revert changes', self
.reload),
102 ('New', gtk
.STOCK_NEW
, '_New Subfile', '<Control>n', 'New file', self
.new
),
103 ('Split', gtk
.STOCK_CONVERT
, '_Convert file->subfile', None, 'Convert file', self
.convert
),
104 ('Rename', gtk
.STOCK_SAVE_AS
, '_Rename subfile', None, 'Rename file', self
.rename
),
105 ('Delete', gtk
.STOCK_DELETE
, '_Delete subfile', None, 'Delete file', self
.deleteFile
),
106 ('File', None, '_File'),
107 ('Save', gtk
.STOCK_SAVE
, '_Save', '<Control>s', 'Save changes', self
.save
),
108 ('Edit', None, '_Edit'),
109 ('Expand All', None, '_Expand All', '<Control>slash', 'Expand Rows', self
.expand
),
110 ('Collapse All', None, '_Collapse All', '<Control>backslash', 'Collapse Rows', self
.collapse
),
111 ('Add Package', gtk
.STOCK_ADD
, '_Add Package', '<Control>t', 'Add a package', rightpanel
.insertrow
),
112 ('Remove Package', gtk
.STOCK_REMOVE
, '_Remove Package', 'Delete', "Remove a package", rightpanel
.deleterow
),
113 ('Comment', gtk
.STOCK_INDENT
, '_Comment', '<Control>period', "Comment a package", self
.comment
),
114 ('Uncomment', gtk
.STOCK_UNINDENT
, '_Uncomment', '<Control>comma', "Uncomment a package", self
.uncomment
),
115 ('View', None, '_View'),
116 ('Help',None,'_Help'),
117 ('About', gtk
.STOCK_ABOUT
, '_About', None, 'About GPytage', self
.about
)])
120 self
.uimanager
.insert_action_group(self
.actiongroup
, 0)
121 self
.uimanager
.add_ui_from_string(self
.ui
)
124 self
.menubar
= self
.uimanager
.get_widget('/MenuBar')
125 self
.toolbar
= self
.uimanager
.get_widget('/ToolBar')
126 self
.vbox
= gtk
.VBox() #the master widgit
127 self
.vbox
.pack_start(self
.menubar
, False)
128 self
.vbox
.pack_start(self
.toolbar
, False)
130 #allow the program to quit
131 self
.window
.connect("destroy", self
.destroy
)
132 self
.window
.connect("delete_event", self
.delete_event
)
135 self
.pane
= gtk
.HPaned()
136 self
.pane
.pack1(leftpanel
.scroll
, True, True)
137 self
.pane
.pack2(rightpanel
.scroll
, True, True)
138 self
.pane
.set_position(200)
139 self
.vbox
.pack_start(self
.pane
)
140 self
.window
.add_accel_group(self
.accelgroup
)
141 self
.window
.add(self
.vbox
)
142 self
.window
.show_all()
144 def destroy(self
, widget
, data
=None):
145 title
= self
.window
.get_title()
146 if title
!= "GPytage":
147 status
, uD
= unsavedDialog()
148 if status
== -8: #YES
150 elif status
== 1: #SAVE
153 else: #NO and other unhandled signals
158 def delete_event(self
, widget
, event
, data
=None):
163 def about(self
, *args
):
164 aboutw
= gtk
.AboutDialog()
165 aboutw
.set_name('GPytage')
166 aboutw
.set_copyright('Copyright 2008, GPL2')
167 aboutw
.set_authors(["Kenneth 'ken69267' Prugh", "\nWith patches contributed by Brian Dolbec \nand Josh 'nightmorph' Saddler. \n\nWith special thanks to the Gentoo \ndevelopers and community. \n\nLicensed under the GPL-2"]) #Fix wording? :)
168 f
=open(config
.PORTDIR
+ '/licenses/GPL-2')
171 aboutw
.set_license(gpl2
)
172 aboutw
.set_wrap_license(True)
173 aboutw
.set_version(version
)
174 aboutw
.set_website('https://gna.org/projects/gpytage/')
176 aboutw
.set_logo(self
.i128
)
178 print "ABOUT(): Logo could not be set"
182 def reload(self
, *args
): #reloads all rows in treeview
185 def expand(self
, *args
):
186 leftpanel
.leftview
.expand_all()
188 def collapse(self
, *args
):
189 leftpanel
.leftview
.collapse_all()
191 def save(self
, *args
):
192 save
.SaveFile().save()
194 def new(self
, *args
):
195 subfile
.new(self
.window
)
197 def convert(self
, *args
):
198 subfile
.convert(self
.window
)
200 def rename(self
, *args
):
201 rename
.rename().renameDialog(self
.window
)
203 def deleteFile(self
, *args
):
204 subfile
.delete(self
.window
)
206 def comment(self
, *args
):
207 rightpanel
.commentRow(self
.window
)
209 def uncomment(self
, *args
):
210 rightpanel
.uncommentRow(self
.window
)
217 print "Usage: gpytage [OPTION...]\n"
218 print " -h, --help" + tabs
+ "Show this help message"
219 print " -l, --local" + tabs
+ \
220 "Run a local version (use modules in current directory)"
221 print " -v, --version" + tabs
+ "Output version information and exit"
222 print " -t, --test" + tabs
+ \
223 "Use the pre-configured test directory instead of '/etc/portage'"
226 if __name__
== "__main__":
228 opts
, args
= getopt(sys
.argv
[1:], 'lvth', ["local", "version", "test",
230 except GetoptError
, e
:
231 print >> sys
.stderr
, e
.msg
237 for opt
, arg
in opts
:
238 if opt
in ("-l", "--local"):
239 # running a local version (i.e. not installed in /usr/*)
240 from os
import getcwd
241 DATA_PATH
= getcwd() + "/"
242 PIXMAPS
= getcwd() + "/pixmaps/"
243 #i18n_DIR = DATA_PATH + 'i18n'
246 from window
import title
, window
, unsavedDialog
249 from panelfunctions
import selected
251 from version
import version
252 from datastore
import datastore
,config_files
,create_treeiter
,create_lists
253 from helper
import reload
256 print "GPytage: starting gpytage()"
258 if not RUN_LOCAL
: # then run the installed modules
260 from gpytage
.version
import version
261 # set data path for our glade and pixmap files
262 DATA_PATH
= "/usr/share/gpytage/"
263 PIXMAPS
= "/usr/share/pixmaps/"
264 #i18n_DIR = DATA_PATH + 'i18n'
265 #i18n_DIR = "/usr/share/locale/"
266 from gpytage
import save
267 from gpytage
import leftpanel
, rightpanel
268 from gpytage
import config
269 from gpytage
.window
import title
, window
, unsavedDialog
270 from gpytage
.version
import version
271 from gpytage
.datastore
import datastore
,config_files
,create_treeiter
,create_lists
272 from gpytage
.helper
import reload
273 from gpytage
import subfile
274 from gpytage
import rename
276 print "GPytage: starting gpytage()"
277 except ImportError, e
:
278 print "*** Error loading gpytage modules!\n*** If you are running a", \
279 "local (not installed in python's site-packages) version, please use the '--local'", \
281 "*** Otherwise, verify that gpytage was installed correctly and", \
282 "that python's path includes the site-packages directory.\n",\
283 "If you have recently updated python, then run 'python-updater'\n"
284 print "Your sys.path: %s\n" % sys
.path
285 print "Your sys.version: %s\n" % sys
.version
286 print "Original exception was: ImportError: %s\n" % e
289 for opt
, arg
in opts
: #broken for now
290 if opt
in ("-t", "--test"):
291 config
.set_test_path()
293 for opt
, arg
in opts
:
294 #print "opt, arg ", opt, arg, type(arg)
295 if opt
in ("-v", "--version"):
297 print "GPytage " + version
300 gpytagemain
= gpytagemain()