/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to window.py

  • Committer: Vincent Ladeuil
  • Date: 2009-05-07 11:48:03 UTC
  • Revision ID: v.ladeuil+lp@free.fr-20090507114803-sxykmkuzrkdj2pr3
Fix bug #373157 by properly setting the default values.

* tests/test_annotate_config.py:
(TestConfig.test_create_initial_config): Urgh, remove pdb breakpoint.

* annotate/config.py:
(gannotate_configspec): Deleted, can't be used for default values
and not used for validation: useless.
(gannotate_config_filename): Turned into a function so that tests
get proper isolated result (evaluating the path at load time
forbids the test framework overriding).
(GAnnotateConfig.__init__): Add default values *only* if the
'window' section doesn't exist. Assigning them unconditionally
defeats the config file purpose... Also delete the 'spans' section
since nobody use it.
(GAnnotateConfig.apply): Coerce config values when we use them.
(Gannotateconfig._save_custom_spans): Deleted (dead code).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
 
from gi.repository import Gdk
3
 
from gi.repository import Gtk
4
 
 
5
 
 
6
 
class Window(Gtk.Window):
 
2
import pygtk
 
3
import gtk
 
4
 
 
5
class Window(gtk.Window):
7
6
 
8
7
    def __init__(self, parent=None):
9
 
        super(Window, self).__init__(type=Gtk.WindowType.TOPLEVEL)
 
8
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
10
9
        self._parent = parent
11
10
 
12
11
        self.connect('key-press-event', self._on_key_press)
13
12
 
14
13
    def _on_key_press(self, widget, event):
15
 
        keyname = Gdk.keyval_name(event.keyval)
16
 
        if event.get_state() & Gdk.ModifierType.CONTROL_MASK:
 
14
        keyname = gtk.gdk.keyval_name(event.keyval)
 
15
        if event.state & gtk.gdk.CONTROL_MASK:
17
16
            if keyname is "w":
18
17
                self.destroy()
19
18
                if self._parent is None:
20
 
                    Gtk.main_quit()
 
19
                    gtk.main_quit()
21
20
            elif keyname is "q":
22
 
                Gtk.main_quit()
 
21
                gtk.main_quit()
23
22