~ubuntu-branches/ubuntu/oneiric/avant-window-navigator/oneiric

« back to all changes in this revision

Viewing changes to awn-manager/awnManager.in.py

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne
  • Date: 2008-05-24 14:42:01 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080524144201-r3v8e4g2hv2q1i9x
Tags: 0.2.6-6
* debian/patches/04-fix-colormap.patch
 - Fix crash in awn-manager if colormap == None. Thanks Emme for the 
   patch. (Closes: #482030) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
#
3
 
#  Copyright (C) 2007 Neil Jagdish Patel <njpatel@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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
18
 
#
19
 
#  Author: Ryan Rushton <ryan@rrdesign.ca>
20
 
#
21
 
#  Notes: Avant Window Navigator Manager
22
 
 
23
 
import sys, os, time
24
 
 
25
 
PKGDATA = "@DATADIR@" + "/avant-window-navigator/awn-manager"
26
 
sys.path.append (PKGDATA)
27
 
 
28
 
try:
29
 
    import pygtk
30
 
    pygtk.require("2.0")
31
 
except:
32
 
        pass
33
 
try:
34
 
    import gtk
35
 
    import gtk.glade
36
 
except Exception, e:
37
 
    sys.stderr.write(str(e) + '\n')
38
 
    sys.exit(1)
39
 
 
40
 
import gconf
41
 
import gnomedesktop
42
 
import gtk.gdk as gdk
43
 
 
44
 
from awnTheme import AwnThemeManager
45
 
from awnPreferences import awnPreferences
46
 
from awnApplet import awnApplet
47
 
from awnLauncher import awnLauncher
48
 
 
49
 
APP = 'avant-window-navigator'
50
 
DIR = "@DATADIR@" + "/locale"
51
 
I18N_DOMAIN = "avant-window-navigator"
52
 
 
53
 
import locale
54
 
import gettext
55
 
locale.setlocale(locale.LC_ALL, '')
56
 
gettext.bindtextdomain(APP, DIR)
57
 
gettext.textdomain(APP)
58
 
_ = gettext.gettext
59
 
 
60
 
 
61
 
class AwnManager:
62
 
 
63
 
    def __init__(self):
64
 
 
65
 
        self.AWN_CONFIG_DIR = os.path.join(os.path.expanduser('~'),'.config/awn')
66
 
        if not os.path.exists(self.AWN_CONFIG_DIR):
67
 
            os.makedirs(self.AWN_CONFIG_DIR)
68
 
        self.GLADE_PATH = os.path.join(PKGDATA, "window.glade")
69
 
        gtk.glade.bindtextdomain(APP, DIR)
70
 
        gtk.glade.textdomain(APP)
71
 
 
72
 
        self.wTree = gtk.glade.XML(self.GLADE_PATH, domain=I18N_DOMAIN)
73
 
 
74
 
        self.window = self.wTree.get_widget("main_window")
75
 
        self.window.connect("delete-event", gtk.main_quit)
76
 
 
77
 
        refresh = self.wTree.get_widget("refreshbutton")
78
 
        refresh.connect("clicked", self.refresh)
79
 
 
80
 
        about = self.wTree.get_widget("aboutbutton")
81
 
        about.connect("clicked", self.about)
82
 
 
83
 
        close = self.wTree.get_widget("closebutton")
84
 
        close.connect("clicked", gtk.main_quit)
85
 
 
86
 
        #menu
87
 
        self.treeview =  self.wTree.get_widget("view_menu")
88
 
        self.treeview.get_selection().connect("changed", self.menu_row_clicked)
89
 
        self.make_menu_model()
90
 
 
91
 
        #theme
92
 
        self.themeManager = AwnThemeManager(self.wTree, self.AWN_CONFIG_DIR)
93
 
 
94
 
        #applet
95
 
        self.appletManager = awnApplet(self.wTree)
96
 
 
97
 
        #launcher
98
 
        self.launchManager = awnLauncher(self.wTree, self.AWN_CONFIG_DIR)
99
 
 
100
 
        #preferences
101
 
        self.prefManager = awnPreferences(self.wTree)
102
 
 
103
 
    def menu_row_clicked(self, data=None):
104
 
        selection = self.treeview.get_selection()
105
 
        (model, iter) = selection.get_selected()
106
 
        if iter != None:
107
 
            self.show_panel(model.get_path(iter)[0])
108
 
 
109
 
    def show_panel(self, index):
110
 
        for panel in ['panel_preferences','panel_applets','panel_launchers','panel_themes']:
111
 
            self.wTree.get_widget(panel).hide()
112
 
        if index == 0:
113
 
            self.wTree.get_widget('panel_preferences').show()
114
 
        elif index == 1:
115
 
            self.wTree.get_widget('panel_applets').show()
116
 
        elif index == 2:
117
 
            self.wTree.get_widget('panel_launchers').show()
118
 
        elif index == 3:
119
 
            self.wTree.get_widget('panel_themes').show()
120
 
 
121
 
 
122
 
    def make_menu_model (self):
123
 
        self.model = model = gtk.ListStore(gdk.Pixbuf, str, str, str)
124
 
        self.treeview.set_model (model)
125
 
 
126
 
        ren = gtk.CellRendererPixbuf()
127
 
        col = gtk.TreeViewColumn ("Pixbuf", ren, pixbuf=0)
128
 
        self.treeview.append_column (col)
129
 
 
130
 
        ren = gtk.CellRendererText()
131
 
        col = gtk.TreeViewColumn ("Name", ren, markup=1)
132
 
        self.treeview.append_column (col)
133
 
 
134
 
        theme = gtk.icon_theme_get_default()
135
 
 
136
 
        row = self.model.append ()
137
 
        self.model.set_value (row, 0, theme.load_icon (gtk.STOCK_PREFERENCES, 32, 0))
138
 
        self.model.set_value (row, 1, "General")
139
 
 
140
 
        row = self.model.append ()
141
 
        self.model.set_value (row, 0, theme.load_icon (gtk.STOCK_SORT_ASCENDING, 32, 0))
142
 
        self.model.set_value (row, 1, "Applets")
143
 
 
144
 
        row = self.model.append ()
145
 
        self.model.set_value (row, 0, theme.load_icon (gtk.STOCK_FULLSCREEN, 32, 0))
146
 
        self.model.set_value (row, 1, "Launchers")
147
 
 
148
 
        row = self.model.append ()
149
 
        self.model.set_value (row, 0, theme.load_icon (gtk.STOCK_HOME, 32, 0))
150
 
        self.model.set_value (row, 1, "Themes")
151
 
 
152
 
        path = self.model.get_path(self.model.get_iter_first())
153
 
        self.treeview.set_cursor(path, focus_column=None, start_editing=False)
154
 
 
155
 
    def refresh(self, button):
156
 
        w = gtk.Window()
157
 
        i = gtk.IconTheme()
158
 
        w.set_icon(i.load_icon("gtk-refresh", 48, gtk.ICON_LOOKUP_FORCE_SVG))
159
 
        v = gtk.VBox()
160
 
        l = gtk.Label("Refreshed")
161
 
        b = gtk.Button(stock="gtk-close")
162
 
        b.connect("clicked", self.win_destroy, w)
163
 
        v.pack_start(l, True, True, 2)
164
 
        v.pack_start(b)
165
 
        w.add(v)
166
 
        w.resize(200, 100)
167
 
        w.show_all()
168
 
 
169
 
    def about(self, button):
170
 
        self.about = gtk.AboutDialog()
171
 
        self.about.set_name("Avant Window Navigator")
172
 
        self.about.set_version("0.2.1")
173
 
        self.about.set_copyright("Copyright (C) 2007 Neil Jagdish Patel <njpatel@gmail.com>")
174
 
        self.about.set_authors(["Neil Jagdish Patel     <njpatel@gmail.com>", "haytjes <hv1989@gmail.com>", "Miika-Petteri Matikainen <miikapetteri@gmail.com>", "Anthony Arobone  <aarobone@gmail.com>", "Ryan Rushton <ryan@rrdesign.ca>", "Michal Hruby  <michal.mhr@gmail.com>", "Julien Lavergne <julien.lavergne@gmail.com>"])
175
 
        self.about.set_comments("Fully customisable dock-like window navigator for GNOME.")
176
 
        self.about.set_license('''
177
 
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
178
 
 
179
 
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
180
 
 
181
 
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.''')
182
 
        self.about.set_wrap_license(True)
183
 
        self.about.set_website("http://www.planetblur.org/hosted/awnforum/")
184
 
        #self.about.set_logo_icon_name(gtk.STOCK_ABOUT)
185
 
        self.about.set_documenters(["More to come..."])
186
 
        self.about.set_artists(["More to come..."])
187
 
        #self.about.set_translator_credits()
188
 
        self.about.run()
189
 
        self.about.destroy()
190
 
 
191
 
    def win_destroy(self, button, w):
192
 
        w.destroy()
193
 
 
194
 
    def main(self):
195
 
        gtk.main()
196
 
 
197
 
if __name__ == "__main__":
198
 
    gettext.textdomain(I18N_DOMAIN)
199
 
    gtk.glade.bindtextdomain(I18N_DOMAIN, "/usr/share/locale")
200
 
    awnmanager = AwnManager()
201
 
    awnmanager.main()