| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | # Copyright (C) 2008 Adriano Monteiro Marques |
|---|
| 3 | # |
|---|
| 4 | # Author: Francesco Piccinno <stack.box@gmail.com> |
|---|
| 5 | # |
|---|
| 6 | # This program is free software; you can redistribute it and/or modify |
|---|
| 7 | # it under the terms of the GNU General Public License as published by |
|---|
| 8 | # the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | # (at your option) any later version. |
|---|
| 10 | # |
|---|
| 11 | # This program is distributed in the hope that it will be useful, |
|---|
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | # GNU General Public License for more details. |
|---|
| 15 | # |
|---|
| 16 | # You should have received a copy of the GNU General Public License |
|---|
| 17 | # along with this program; if not, write to the Free Software |
|---|
| 18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | |
|---|
| 20 | import gtk |
|---|
| 21 | import os.path |
|---|
| 22 | |
|---|
| 23 | from higwidgets.higwindows import HIGWindow |
|---|
| 24 | from higwidgets.higboxes import HIGVBox |
|---|
| 25 | |
|---|
| 26 | from higwidgets.higanimates import HIGAnimatedBar |
|---|
| 27 | from higwidgets.higtoolbars import HIGToolBar, HIGToolItem |
|---|
| 28 | |
|---|
| 29 | from PathPage import PathPage |
|---|
| 30 | from PluginPage import PluginPage |
|---|
| 31 | |
|---|
| 32 | from umit.core.Paths import Path |
|---|
| 33 | from umit.plugin.Update import UpdateEngine |
|---|
| 34 | from umit.plugin.Engine import PluginEngine |
|---|
| 35 | |
|---|
| 36 | from Network import * |
|---|
| 37 | |
|---|
| 38 | from umit.core.I18N import _ |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | class PluginWindow(HIGWindow): |
|---|
| 42 | def __init__(self): |
|---|
| 43 | HIGWindow.__init__(self) |
|---|
| 44 | |
|---|
| 45 | self.engine = PluginEngine() |
|---|
| 46 | self.update_eng = UpdateEngine() |
|---|
| 47 | |
|---|
| 48 | self.set_title(_('Plugin Manager')) |
|---|
| 49 | self.set_position(gtk.WIN_POS_CENTER) |
|---|
| 50 | self.set_size_request(600, 400) |
|---|
| 51 | self.set_icon_from_file(os.path.join(Path.icons_dir, "umit_16.ico")) |
|---|
| 52 | |
|---|
| 53 | self.__create_widgets() |
|---|
| 54 | self.__pack_widgets() |
|---|
| 55 | |
|---|
| 56 | def __create_widgets(self): |
|---|
| 57 | self.vbox = HIGVBox() |
|---|
| 58 | |
|---|
| 59 | self.animated_bar = HIGAnimatedBar('') |
|---|
| 60 | self.toolbar = HIGToolBar() |
|---|
| 61 | |
|---|
| 62 | self.notebook = gtk.Notebook() |
|---|
| 63 | self.notebook.set_show_tabs(False) |
|---|
| 64 | self.notebook.set_show_border(False) |
|---|
| 65 | |
|---|
| 66 | self.plug_page = PluginPage(self) |
|---|
| 67 | self.path_page = PathPage(self) |
|---|
| 68 | |
|---|
| 69 | def __pack_widgets(self): |
|---|
| 70 | self.add(self.vbox) |
|---|
| 71 | |
|---|
| 72 | self.vbox.pack_start(self.animated_bar, False, False, 0) |
|---|
| 73 | self.vbox.pack_start(self.toolbar, False, False, 0) |
|---|
| 74 | self.vbox.pack_start(self.notebook) |
|---|
| 75 | |
|---|
| 76 | self.notebook.append_page(self.plug_page) |
|---|
| 77 | self.notebook.append_page(self.path_page) |
|---|
| 78 | |
|---|
| 79 | self.toolbar.connect('changed', self.__on_switch_page) |
|---|
| 80 | |
|---|
| 81 | self.connect('realize', self.__on_realize) |
|---|
| 82 | |
|---|
| 83 | # Create the pages |
|---|
| 84 | |
|---|
| 85 | lbls = (_('Extensions'), _('Paths')) |
|---|
| 86 | imgs = ('extension_small', 'paths_small') |
|---|
| 87 | |
|---|
| 88 | for lbl, stock in zip(lbls, imgs): |
|---|
| 89 | image = gtk.image_new_from_stock(stock, gtk.ICON_SIZE_MENU) |
|---|
| 90 | |
|---|
| 91 | self.toolbar.append( |
|---|
| 92 | HIGToolItem('<b>%s</b>' % lbl, image) |
|---|
| 93 | ) |
|---|
| 94 | |
|---|
| 95 | self.toolbar.set_active(0) |
|---|
| 96 | self.get_child().show_all() # No show the root |
|---|
| 97 | |
|---|
| 98 | # We have to hide unused buttons in plugin page |
|---|
| 99 | self.plug_page.install_updates_btn.hide() |
|---|
| 100 | self.plug_page.skip_install_btn.hide() |
|---|
| 101 | self.plug_page.restart_btn.hide() |
|---|
| 102 | |
|---|
| 103 | self.connect('delete-event', self.__on_delete_event) |
|---|
| 104 | |
|---|
| 105 | def __on_delete_event(self, widget, evt): |
|---|
| 106 | self.hide() |
|---|
| 107 | return True |
|---|
| 108 | |
|---|
| 109 | def __on_realize(self, widget): |
|---|
| 110 | self.animated_bar.hide() |
|---|
| 111 | |
|---|
| 112 | self.plug_page.populate() |
|---|
| 113 | self.path_page.populate() |
|---|
| 114 | |
|---|
| 115 | def __on_switch_page(self, widget, id): |
|---|
| 116 | self.notebook.set_current_page(id) |
|---|