A4

Merge lp:~andrea.corbellini/a4/close-file into lp:a4

Proposed by Andrea Corbellini
Status: Merged
Merged at revision: 3
Proposed branch: lp:~andrea.corbellini/a4/close-file
Merge into: lp:a4
Diff against target: 83 lines (+32/-4)
2 files modified
a4lib/app.py (+24/-4)
ui/window_main.glade (+8/-0)
To merge this branch: bzr merge lp:~andrea.corbellini/a4/close-file
Reviewer Review Type Date Requested Status
Andrea Colangelo Approve
Review via email: mp+26299@code.launchpad.net

Commit message

Add a 'Close' button to the main window.

Description of the change

This is just a trivial change. I've added a 'Close' button to the main window.

To post a comment you must log in.
Revision history for this message
Andrea Colangelo (warp10) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'a4lib/app.py'
--- a4lib/app.py 2010-05-27 14:23:58 +0000
+++ a4lib/app.py 2010-05-28 13:09:30 +0000
@@ -12,15 +12,14 @@
12 """The main window of the application."""12 """The main window of the application."""
1313
14 def __init__(self):14 def __init__(self):
15 self.svg_image = None
16 self.builder = gtk.Builder()15 self.builder = gtk.Builder()
17 # TODO Look into '/usr/share' too.16 # TODO Look into '/usr/share' too.
18 self.builder.add_from_file('ui/window_main.glade')17 self.builder.add_from_file('ui/window_main.glade')
19 self.builder.connect_signals(self)18 self.builder.connect_signals(self)
20
21 self.gtk_window = self.builder.get_object('window_main')19 self.gtk_window = self.builder.get_object('window_main')
22 self.gtk_window.show_all()20 self.gtk_window.show_all()
23 self.drawing_area = self.builder.get_object('drawing_area').window21 self.drawing_area = self.builder.get_object('drawing_area').window
22 self.reset()
2423
25 def set_status(self, status):24 def set_status(self, status):
26 """Put the given string in the status bar."""25 """Put the given string in the status bar."""
@@ -44,13 +43,30 @@
44 dialog.destroy()43 dialog.destroy()
45 else:44 else:
46 # The file was OK. Set up the environment.45 # The file was OK. Set up the environment.
47 widget = self.builder.get_object('drawing_area')
48 widget.set_size_request(image.width + 20, image.height + 20)
49 self.svg_image = image46 self.svg_image = image
47 area = self.builder.get_object('drawing_area')
48 area.set_size_request(image.width + 20, image.height + 20)
49 # Make the 'Close' button sensitive.
50 menu_item = self.builder.get_object('imagemenuitem_close')
51 menu_item.props.sensitive = True
50 finally:52 finally:
51 # Restore the status string.53 # Restore the status string.
52 self.set_status('')54 self.set_status('')
5355
56 def reset(self):
57 """Reset the environment and put the window into its original state.
58
59 This function closes the file (if opened) and resets all the buttons
60 and the menus.
61 """
62 # Destroy the image object and reset the drawing area's size.
63 self.svg_image = None
64 area = self.builder.get_object('drawing_area')
65 area.set_size_request(0, 0)
66 # Make the 'Close' button insensitive.
67 menu_item = self.builder.get_object('imagemenuitem_close')
68 menu_item.props.sensitive = False
69
54 def on_open_clicked(self, widget):70 def on_open_clicked(self, widget):
55 """Even called when the 'Open' button is clicked."""71 """Even called when the 'Open' button is clicked."""
56 # Set up the file chooser dialog.72 # Set up the file chooser dialog.
@@ -74,6 +90,10 @@
74 if response == gtk.RESPONSE_OK:90 if response == gtk.RESPONSE_OK:
75 self.open_file(file_name)91 self.open_file(file_name)
7692
93 def on_close_clicked(self, widget):
94 """The 'Close' button has been clicked."""
95 self.reset()
96
77 def on_drawing_area_expose(self, widget, event):97 def on_drawing_area_expose(self, widget, event):
78 """This method is called everytime the drawing area should be redrawn.98 """This method is called everytime the drawing area should be redrawn.
79 """99 """
80100
=== modified file 'ui/window_main.glade'
--- ui/window_main.glade 2010-05-27 14:23:58 +0000
+++ ui/window_main.glade 2010-05-28 13:09:30 +0000
@@ -35,6 +35,14 @@
35 </object>35 </object>
36 </child>36 </child>
37 <child>37 <child>
38 <object class="GtkImageMenuItem" id="imagemenuitem_close">
39 <property name="label">gtk-close</property>
40 <property name="visible">True</property>
41 <property name="use_stock">True</property>
42 <signal name="activate" handler="on_close_clicked"/>
43 </object>
44 </child>
45 <child>
38 <object class="GtkImageMenuItem" id="imagemenuitem_quit">46 <object class="GtkImageMenuItem" id="imagemenuitem_quit">
39 <property name="label">gtk-quit</property>47 <property name="label">gtk-quit</property>
40 <property name="visible">True</property>48 <property name="visible">True</property>

Subscribers

People subscribed via source and target branches