Andrea Corbellini has proposed merging lp:~andrea-bs/a4/close-file into lp:a4.
Requested reviews: A4 development (a4-dev) This is just a trivial change. I've added a 'Close' button to the main window. -- https://code.launchpad.net/~andrea-bs/a4/close-file/+merge/26299 Your team A4 development is requested to review the proposed merge of lp:~andrea-bs/a4/close-file into lp:a4.
=== 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 @@ """The main window of the application.""" def __init__(self): - self.svg_image = None self.builder = gtk.Builder() # TODO Look into '/usr/share' too. self.builder.add_from_file('ui/window_main.glade') self.builder.connect_signals(self) - self.gtk_window = self.builder.get_object('window_main') self.gtk_window.show_all() self.drawing_area = self.builder.get_object('drawing_area').window + self.reset() def set_status(self, status): """Put the given string in the status bar.""" @@ -44,13 +43,30 @@ dialog.destroy() else: # The file was OK. Set up the environment. - widget = self.builder.get_object('drawing_area') - widget.set_size_request(image.width + 20, image.height + 20) self.svg_image = image + area = self.builder.get_object('drawing_area') + area.set_size_request(image.width + 20, image.height + 20) + # Make the 'Close' button sensitive. + menu_item = self.builder.get_object('imagemenuitem_close') + menu_item.props.sensitive = True finally: # Restore the status string. self.set_status('') + def reset(self): + """Reset the environment and put the window into its original state. + + This function closes the file (if opened) and resets all the buttons + and the menus. + """ + # Destroy the image object and reset the drawing area's size. + self.svg_image = None + area = self.builder.get_object('drawing_area') + area.set_size_request(0, 0) + # Make the 'Close' button insensitive. + menu_item = self.builder.get_object('imagemenuitem_close') + menu_item.props.sensitive = False + def on_open_clicked(self, widget): """Even called when the 'Open' button is clicked.""" # Set up the file chooser dialog. @@ -74,6 +90,10 @@ if response == gtk.RESPONSE_OK: self.open_file(file_name) + def on_close_clicked(self, widget): + """The 'Close' button has been clicked.""" + self.reset() + def on_drawing_area_expose(self, widget, event): """This method is called everytime the drawing area should be redrawn. """ === 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 @@ </object> </child> <child> + <object class="GtkImageMenuItem" id="imagemenuitem_close"> + <property name="label">gtk-close</property> + <property name="visible">True</property> + <property name="use_stock">True</property> + <signal name="activate" handler="on_close_clicked"/> + </object> + </child> + <child> <object class="GtkImageMenuItem" id="imagemenuitem_quit"> <property name="label">gtk-quit</property> <property name="visible">True</property>
_______________________________________________ Mailing list: https://launchpad.net/~a4-dev Post to : a4-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~a4-dev More help : https://help.launchpad.net/ListHelp