diff options
Diffstat (limited to 'demos/gtk-demo/demos/appwindow.py')
-rw-r--r-- | demos/gtk-demo/demos/appwindow.py | 64 |
1 files changed, 19 insertions, 45 deletions
diff --git a/demos/gtk-demo/demos/appwindow.py b/demos/gtk-demo/demos/appwindow.py index 8b7c99c3..a71720f9 100644 --- a/demos/gtk-demo/demos/appwindow.py +++ b/demos/gtk-demo/demos/appwindow.py @@ -24,11 +24,9 @@ description = """ Demonstrates a typical application window with menubar, toolbar, statusbar. """ -# See FIXME's -is_fully_bound = False - from gi.repository import Gtk, GdkPixbuf, Gdk import sys, os +import glib global infobar global window @@ -38,7 +36,7 @@ global _demoapp def widget_destroy(widget, button): widget.destroy() -def activate_action(action): +def activate_action(action, user_data): global window name = action.get_name() @@ -50,16 +48,15 @@ def activate_action(action): return - dialog = Gtk.MessageDialog(message_type=Gtk.MessageType.INFO, + dialog = Gtk.MessageDialog(parent=window, + message_type=Gtk.MessageType.INFO, buttons=Gtk.ButtonsType.CLOSE, text='You activated action: "%s" of type %s' % (name, _type)) - # FIXME: this should be done in the constructor - dialog.set_transient_for(window) dialog.connect('response', widget_destroy) dialog.show() -def activate_radio_action(action, current): +def activate_radio_action(action, current, user_data): global infobar global messagelabel @@ -87,29 +84,7 @@ def update_statusbar(buffer, statusbar): def mark_set_callback(buffer, new_location, mark, data): update_statusbar(buffer, data) -def update_resize_grip(widget, event, statusbar): - # FIXME: for some reason we get attribute errors in handlers - # if we try to access flags without first evaluating - # the parent struct - Gdk.WindowState - - # FIXME: event should be a Gdk.EventWindowState but is only a Gdk.Event - if event.window_state.changed_mask and (Gdk.WindowState.MAXIMIZED or - Gdk.WindowState.FULLSCREEN): - - maximized = event.window_state.new_window_state and (Gdk.WindowState.MAXIMIZED or - Gdk.WindowState.FULLSCREEN) - statusbar.set_has_resize_grip(not maximized) - -def activate_email(about, link, data): - text = 'send mail to %s' % (link,) - print text - -def activate_url(about, link, data): - text = 'show url %s' % (link,) - print text - -def about_cb(widget): +def about_cb(widget, data): global window authors = ['John (J5) Palmieri', @@ -137,13 +112,16 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. """ filename = os.path.join('data', 'gtk-logo-rgb.gif') - pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename) + try: + pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename) + except glib.GError: + filename = os.path.join('demos', filename) + pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename) + transparent = pixbuf.add_alpha(True, 0xff, 0xff, 0xff) - Gtk.AboutDialog.set_email_hook(activate_email, None) - Gtk.AboutDialog.set_url_hook(activate_url, None) - # FIXME: override Gtk.show_about_dialog - # make about dailog constructor take a parent argument - about = Gtk.AboutDialog(program_name='GTK+ Code Demos', + about = Gtk.AboutDialog( + parent=window, + program_name='GTK+ Code Demos', version='0.1', copyright='(C) 2010 The PyGI Team', license=license, @@ -152,12 +130,10 @@ Boston, MA 02111-1307, USA. authors=authors, documenters=documentors, logo=transparent, - title='About GTK+ Code Demos') + title='About GTK+ Code Demos') - about.set_transient_for(window) about.connect('response', widget_destroy) - about.show() - + about.run() action_entries = ( ("FileMenu", None, "_File"), # name, stock id, label @@ -337,8 +313,8 @@ def main(demoapp=None): window.set_title('Application Window') window.set_icon_name('gtk-open') window.connect_after('destroy', _quit) - table = Gtk.Table(n_rows=1, - n_columns=5, + table = Gtk.Table(rows=1, + columns=5, homogeneous=False) window.add(table) @@ -412,8 +388,6 @@ def main(demoapp=None): buffer.connect('changed', update_statusbar, statusbar) buffer.connect('mark_set', mark_set_callback, statusbar) - window.connect('window_state_event', update_resize_grip, statusbar) - update_statusbar(buffer, statusbar); window.set_default_size(200, 200) |