| 1 | # Copyright (C) 2008 Adriano Monteiro Marques. |
|---|
| 2 | # |
|---|
| 3 | # Author: Luis A. Bastiao Silva <luis.kop@gmail.com> |
|---|
| 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, write to the Free Software |
|---|
| 17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 18 | |
|---|
| 19 | import os |
|---|
| 20 | import gtk |
|---|
| 21 | import gobject |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | from umitCore.UmitLogging import log |
|---|
| 25 | from umitCore.I18N import _ |
|---|
| 26 | |
|---|
| 27 | ############ |
|---|
| 28 | # Get Class |
|---|
| 29 | from umitPreferences.GeneralSettings import * |
|---|
| 30 | from umitPreferences.Interfaces import InterfaceDetails |
|---|
| 31 | from umitPreferences.Expose import ExposeGeneral |
|---|
| 32 | |
|---|
| 33 | import umitPreferences.Interfaces |
|---|
| 34 | import umitPreferences.Expose |
|---|
| 35 | ############## |
|---|
| 36 | from umitPreferences.widgets.VTab import IconScroller |
|---|
| 37 | |
|---|
| 38 | from umitCore.Paths import Path |
|---|
| 39 | pixmap = Path.pixmaps_dir |
|---|
| 40 | |
|---|
| 41 | class VTabManager(gtk.VBox): |
|---|
| 42 | def __init__(self): |
|---|
| 43 | gtk.VBox.__init__(self) |
|---|
| 44 | self.set_spacing(10) |
|---|
| 45 | self.set_border_width(0) |
|---|
| 46 | self.grab_focus() |
|---|
| 47 | self.fields = [] |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | # General: |
|---|
| 52 | self.fields.append({'name':_('General'), |
|---|
| 53 | 'image':'general-m.svg', |
|---|
| 54 | 'class': GeneralSettings, |
|---|
| 55 | 'cb':self._change_page_general}) |
|---|
| 56 | |
|---|
| 57 | # Expose : |
|---|
| 58 | |
|---|
| 59 | items = [] |
|---|
| 60 | factory = umitPreferences.Expose.Factory() |
|---|
| 61 | |
|---|
| 62 | items.append({'name':_('Customize'), |
|---|
| 63 | 'box': factory.create("settings")}) |
|---|
| 64 | |
|---|
| 65 | items.append({'name':_('Profiles'), |
|---|
| 66 | 'box': factory.create("profiles")}) |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | items.append({'name':_('Window'), |
|---|
| 70 | 'box': factory.create("window")}) |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | self.fields.append({'name':_('Expose'), |
|---|
| 74 | 'image':'expose-m.svg', |
|---|
| 75 | 'class': ExposeGeneral, |
|---|
| 76 | 'cb':self._change_page_expose, |
|---|
| 77 | 'items':items}) |
|---|
| 78 | |
|---|
| 79 | # Interface / Details : |
|---|
| 80 | |
|---|
| 81 | items = [] |
|---|
| 82 | factory = umitPreferences.Interfaces.Factory() |
|---|
| 83 | |
|---|
| 84 | items.append({'name':_('Diff Colours'), |
|---|
| 85 | 'box': factory.create("diff")}) |
|---|
| 86 | |
|---|
| 87 | items.append({'name':_('Nmap Results'), |
|---|
| 88 | 'box': factory.create("nmap")}) |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | items.append({'name':_('Search'), |
|---|
| 92 | 'box': factory.create("search")}) |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | self.fields.append({'name':_('Nmap/Interface'), |
|---|
| 96 | 'image':'fonts-m.svg', |
|---|
| 97 | 'items':items, |
|---|
| 98 | 'class': InterfaceDetails, |
|---|
| 99 | 'cb':self._change_page_interface}) |
|---|
| 100 | |
|---|
| 101 | self.fields.append({'name':_('Scan Details'), |
|---|
| 102 | 'image':'fonts-m.svg', |
|---|
| 103 | 'class': InterfaceDetails, |
|---|
| 104 | 'cb':self._change_page_interface}) |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | self.fields.append({'name':_('Scan Details'), |
|---|
| 108 | 'image':'fonts-m.svg', |
|---|
| 109 | 'class': InterfaceDetails, |
|---|
| 110 | 'cb':self._change_page_interface}) |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | self.fields.append({'name':_('Mapper'), |
|---|
| 114 | 'image':'fonts-m.svg', |
|---|
| 115 | 'class': InterfaceDetails, |
|---|
| 116 | 'cb':self._change_page_interface}) |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | for i in self.fields: |
|---|
| 121 | if i.has_key('items'): |
|---|
| 122 | item = i['items'] |
|---|
| 123 | else: |
|---|
| 124 | item = None |
|---|
| 125 | icont = IconScroller(i['name'],\ |
|---|
| 126 | os.path.join(pixmap, \ |
|---|
| 127 | "Preferences" , i['image']), |
|---|
| 128 | item) |
|---|
| 129 | i['icont'] = icont |
|---|
| 130 | icont.set_size_request(-1,25) |
|---|
| 131 | self.pack_start(icont, False, False) |
|---|
| 132 | icont.connect("changed", i['cb']) |
|---|
| 133 | def _change_page_interface(self, widget, num): |
|---|
| 134 | if num == 0: |
|---|
| 135 | return False |
|---|
| 136 | menu = self.fields[2] |
|---|
| 137 | page = menu['items'][num-1] |
|---|
| 138 | self.change_page(page['box']) |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | |
|---|
| 142 | def _change_page_expose(self, widget, num): |
|---|
| 143 | |
|---|
| 144 | if num == 0: |
|---|
| 145 | return False |
|---|
| 146 | menu = self.fields[1] |
|---|
| 147 | page = menu['items'][num-1] |
|---|
| 148 | self.change_page(page['box']) |
|---|
| 149 | |
|---|
| 150 | def _change_page_general(self, widget, num): |
|---|
| 151 | self.change_page(GeneralSettings(_('General Settings'))) |
|---|
| 152 | |
|---|
| 153 | def change_page(self, page): |
|---|
| 154 | """ |
|---|
| 155 | Change page on main window |
|---|
| 156 | """ |
|---|
| 157 | |
|---|
| 158 | # Get main window |
|---|
| 159 | pw = self.get_main_window() |
|---|
| 160 | pw.change_page(page) |
|---|
| 161 | |
|---|
| 162 | def get_main_window(self): |
|---|
| 163 | return self.get_parent().get_parent() |
|---|