~ubuntu-branches/ubuntu/lucid/awn-extras-applets/lucid

« back to all changes in this revision

Viewing changes to applets/maintained/slickswitcher/prefs.py

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne
  • Date: 2010-03-30 20:26:40 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100330202640-vza3bdnv9gc9bg5z
Tags: 0.4.0~rc1-0ubuntu1
* New upstream release (rc1) (LP: #551309)
 - Stack applet close on click (LP: #261520)
* debian/patches/
 - 03-remove-cairo-menu-pref.patch: From upstream (r1244 + r1245 + r1252),
   remove menu entry for cairo-menu preferences, it's not implemented
   (LP: #511254)
 - 04-tomboy-threading-free.patch: From upstream (r1246), remove threading to
   make the applet working. 
* debian/*.install: Update installation location of comics and digital 
  applets.
* debian/control: 
 - Move digital applet from python to C, and add proper Replaces.
 - Add Replaces for awn-applets-c-core to handle migration from 0.3.2.2.
   (LP: #524559)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
19
# Boston, MA 02111-1307, USA.
20
20
 
 
21
import os
 
22
 
21
23
import pygtk
22
24
pygtk.require('2.0')
23
25
import gtk
24
26
import pango
 
27
import gettext
 
28
 
25
29
import awn
26
30
 
27
31
from desktopagnostic.config import GROUP_DEFAULT
30
34
 
31
35
from awn.extras import _
32
36
 
 
37
gettext.bindtextdomain('xdg-user-dirs', '/usr/share/locale')
 
38
 
33
39
 
34
40
class Prefs:
35
41
    defaults = {}
256
262
        label_width = gtk.Label(_("Width:"))
257
263
        label_width.set_alignment(0.0, 0.5)
258
264
        width = self.config.get_value(GROUP_DEFAULT, 'width')
259
 
        if width < 24 or width > 250:
 
265
        if width < 24 or width > 400:
260
266
            width = 160
261
 
        width_adj = gtk.Adjustment(float(width), 24, 250, 5, 10, 0)
 
267
        width_adj = gtk.Adjustment(float(width), 24, 400, 5, 10, 0)
262
268
        width = gtk.SpinButton(width_adj, 1, 0)
263
269
        width.key = 'width'
264
270
        width.connect('focus-out-event', self.spinbutton_focusout)
273
279
        label_height = gtk.Label(_("Height:"))
274
280
        label_height.set_alignment(0.0, 0.5)
275
281
        height = self.config.get_value(GROUP_DEFAULT, 'height')
276
 
        if height < 24 or height > 250:
 
282
        if height < 24 or height > 400:
277
283
            height = 110
278
 
        height_adj = gtk.Adjustment(float(height), 24, 250, 5, 10, 0)
 
284
        height_adj = gtk.Adjustment(float(height), 24, 400, 5, 10, 0)
279
285
        height = gtk.SpinButton(height_adj, 1, 0)
280
286
        height.key = 'height'
281
287
        height.connect('focus-out-event', self.spinbutton_focusout)
333
339
        label_file = gtk.Label(_("File:"))
334
340
 
335
341
        file_chooser = gtk.FileChooserButton(_("Choose a Background Image"))
336
 
        file_chooser.set_filename('')
 
342
        file_chooser.connect('file-set', self.file_chooser_set)
 
343
 
 
344
        path = self.config.get_value(GROUP_DEFAULT, 'background_file')
 
345
        if path in (None, '', os.environ['HOME'], os.environ['HOME'] + '/', '/dev/null', '/'):
 
346
            file_chooser.set_filename(os.environ['HOME'] + '/' + \
 
347
                gettext.dgettext('xdg-user-dirs', 'Pictures'))
 
348
 
 
349
        else:
 
350
            file_chooser.set_filename(path)
337
351
 
338
352
        size_group.add_widget(file_chooser)
339
353
 
341
355
        self.file_hbox.pack_start(label_file, False)
342
356
        self.file_hbox.pack_end(file_chooser, False)
343
357
 
 
358
        if mode != 'file':
 
359
            self.file_hbox.set_sensitive(False)
 
360
 
344
361
        vbox.pack_start(self.file_hbox, False)
345
362
 
346
363
        align = gtk.Alignment(xscale=1.0)
355
372
        vbox.pack_start(label_background, False)
356
373
        vbox.pack_start(align, False)
357
374
 
358
 
        vbox.set_sensitive(False)
359
 
 
360
375
        advanced_vbox.pack_start(vbox, False)
361
376
 
 
377
        self.combo_mode.connect('changed', self.combo_mode_changed)
 
378
 
362
379
        notebook.append_page(advanced_vbox, gtk.Label(_("Advanced")))
363
380
 
364
381
        #Close button in an HButtonBox
373
390
        self.win.add(main_vbox)
374
391
        self.win.show_all()
375
392
 
376
 
    #A value was updated
377
 
    def update(self, widget, event):
378
 
        self.config.set_value(GROUP_DEFAULT, widget.key, widget.get_text())
 
393
    def combo_mode_changed(self, widget):
 
394
        self.applet.settings['background_mode'] = ['gnome', 'compiz', 'file'][widget.get_active()]
 
395
 
 
396
        if widget.get_active() == 2:
 
397
            self.file_hbox.set_sensitive(True)
 
398
 
 
399
        else:
 
400
            self.file_hbox.set_sensitive(False)
 
401
 
 
402
        self.applet.update_backgrounds(True)
 
403
        self.applet.update_icon()
 
404
 
 
405
    def file_chooser_set(self, widget):
 
406
        self.applet.settings['background_file'] = widget.get_filename()
 
407
        if self.combo_mode.get_active() == 2:
 
408
            self.applet.update_backgrounds(True)
 
409
            self.applet.update_icon()
379
410
 
380
411
    #The close button was clicked
381
412
    def close(self, widget):