cairo-appbase 0.3 → 0.4
raw patch · 4 files changed
+357/−392 lines, 4 filesdep −glade
Dependencies removed: glade
Files
- cairo-appbase.cabal +7/−7
- data/main.glade +0/−358
- data/main.ui +318/−0
- src/cairo-appbase.hs +32/−27
cairo-appbase.cabal view
@@ -1,8 +1,8 @@ Name: cairo-appbase -Version: 0.3+Version: 0.4 -Synopsis: A template for building new GUI applications using GTK, Glade and Cairo.+Synopsis: A template for building new GUI applications using GTK and Cairo. Description: This template includes working callbacks to handle the File and Help@@ -18,12 +18,12 @@ > git clone git://github.com/kfish/cairo-appbase.git . To add widgets, install glade from your distro system and run- @glade data/main.glade@+ @glade data/main.ui@. Save the resulting file in GtkBuilder format. .- Note that you must run @cabal install@ to put the glade file in the correct+ Note that you must run @cabal install@ to put the UI file in the correct place for your application to pick it up. To modify the code, edit @src/cairo-appbase.hs@. Hooking up functions to widgets is very simple: get- a widget by name (which you set in glade file), and hook one of its+ a widget by name (which you set in ui file), and hook one of its signals (which you found in the Signals tab in glade) to an @IO ()@ action: . > cut1 <- get G.castToMenuItem "cut1"@@ -62,7 +62,7 @@ Cabal-Version: >= 1.8 Build-type: Simple-Data-Files: data/main.glade+Data-Files: data/main.ui flag splitBase description: Use the split-up base package.@@ -77,7 +77,7 @@ Main-Is: cairo-appbase.hs Hs-Source-Dirs: src- Build-Depends: glib, gtk, glade, cairo+ Build-Depends: glib, gtk, cairo ------------------------------------------------------------------------ -- Git repo
− data/main.glade
@@ -1,358 +0,0 @@-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">--<glade-interface>--<widget class="GtkWindow" id="window1">- <property name="visible">True</property>- <property name="title" translatable="yes">window1</property>- <property name="type">GTK_WINDOW_TOPLEVEL</property>- <property name="window_position">GTK_WIN_POS_NONE</property>- <property name="modal">False</property>- <property name="resizable">True</property>- <property name="destroy_with_parent">False</property>- <property name="decorated">True</property>- <property name="skip_taskbar_hint">False</property>- <property name="skip_pager_hint">False</property>- <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>- <property name="focus_on_map">True</property>- <property name="urgency_hint">False</property>-- <child>- <widget class="GtkVBox" id="vbox1">- <property name="visible">True</property>- <property name="homogeneous">False</property>- <property name="spacing">0</property>-- <child>- <widget class="GtkMenuBar" id="menubar1">- <property name="visible">True</property>- <property name="pack_direction">GTK_PACK_DIRECTION_LTR</property>- <property name="child_pack_direction">GTK_PACK_DIRECTION_LTR</property>-- <child>- <widget class="GtkMenuItem" id="menuitem1">- <property name="visible">True</property>- <property name="label" translatable="yes">_File</property>- <property name="use_underline">True</property>-- <child>- <widget class="GtkMenu" id="menu1">-- <child>- <widget class="GtkImageMenuItem" id="new1">- <property name="visible">True</property>- <property name="label">gtk-new</property>- <property name="use_stock">True</property>- <signal name="activate" handler="on_new1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT"/>- </widget>- </child>-- <child>- <widget class="GtkImageMenuItem" id="open1">- <property name="visible">True</property>- <property name="label">gtk-open</property>- <property name="use_stock">True</property>- <signal name="activate" handler="on_open1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT"/>- </widget>- </child>-- <child>- <widget class="GtkImageMenuItem" id="save1">- <property name="visible">True</property>- <property name="label">gtk-save</property>- <property name="use_stock">True</property>- <signal name="activate" handler="on_save1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT"/>- </widget>- </child>-- <child>- <widget class="GtkImageMenuItem" id="save_as1">- <property name="visible">True</property>- <property name="label">gtk-save-as</property>- <property name="use_stock">True</property>- <signal name="activate" handler="on_save_as1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT"/>- </widget>- </child>-- <child>- <widget class="GtkSeparatorMenuItem" id="separatormenuitem1">- <property name="visible">True</property>- </widget>- </child>-- <child>- <widget class="GtkImageMenuItem" id="quit1">- <property name="visible">True</property>- <property name="label">gtk-quit</property>- <property name="use_stock">True</property>- <signal name="activate" handler="on_quit1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT"/>- </widget>- </child>- </widget>- </child>- </widget>- </child>-- <child>- <widget class="GtkMenuItem" id="menuitem2">- <property name="visible">True</property>- <property name="label" translatable="yes">_Edit</property>- <property name="use_underline">True</property>-- <child>- <widget class="GtkMenu" id="menu2">-- <child>- <widget class="GtkImageMenuItem" id="cut1">- <property name="visible">True</property>- <property name="label">gtk-cut</property>- <property name="use_stock">True</property>- <signal name="activate" handler="on_cut1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT"/>- </widget>- </child>-- <child>- <widget class="GtkImageMenuItem" id="copy1">- <property name="visible">True</property>- <property name="label">gtk-copy</property>- <property name="use_stock">True</property>- <signal name="activate" handler="on_copy1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT"/>- </widget>- </child>-- <child>- <widget class="GtkImageMenuItem" id="paste1">- <property name="visible">True</property>- <property name="label">gtk-paste</property>- <property name="use_stock">True</property>- <signal name="activate" handler="on_paste1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT"/>- </widget>- </child>-- <child>- <widget class="GtkImageMenuItem" id="delete1">- <property name="visible">True</property>- <property name="label">gtk-delete</property>- <property name="use_stock">True</property>- <signal name="activate" handler="on_delete1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT"/>- </widget>- </child>- </widget>- </child>- </widget>- </child>-- <child>- <widget class="GtkMenuItem" id="menuitem3">- <property name="visible">True</property>- <property name="label" translatable="yes">_View</property>- <property name="use_underline">True</property>-- <child>- <widget class="GtkMenu" id="menu3">- </widget>- </child>- </widget>- </child>-- <child>- <widget class="GtkMenuItem" id="menuitem4">- <property name="visible">True</property>- <property name="label" translatable="yes">_Help</property>- <property name="use_underline">True</property>-- <child>- <widget class="GtkMenu" id="menu4">-- <child>- <widget class="GtkMenuItem" id="about1">- <property name="visible">True</property>- <property name="label" translatable="yes">_About</property>- <property name="use_underline">True</property>- <signal name="activate" handler="on_about1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT"/>- </widget>- </child>- </widget>- </child>- </widget>- </child>- </widget>- <packing>- <property name="padding">0</property>- <property name="expand">False</property>- <property name="fill">False</property>- </packing>- </child>-- <child>- <widget class="GtkDrawingArea" id="drawingarea1">- <property name="visible">True</property>- </widget>- <packing>- <property name="padding">0</property>- <property name="expand">True</property>- <property name="fill">True</property>- </packing>- </child>-- <child>- <widget class="GtkStatusbar" id="statusbar1">- <property name="visible">True</property>- <property name="has_resize_grip">True</property>- </widget>- <packing>- <property name="padding">0</property>- <property name="expand">False</property>- <property name="fill">False</property>- </packing>- </child>- </widget>- </child>-</widget>--<widget class="GtkAboutDialog" id="aboutdialog1">- <property name="destroy_with_parent">False</property>- <property name="name" translatable="yes">Application Name</property>- <property name="wrap_license">False</property>- <property name="translator_credits" translatable="yes" comments="TRANSLATORS: Replace this string with your names, one name per line.">translator-credits</property>-</widget>--<widget class="GtkFileChooserDialog" id="opendialog">- <property name="action">GTK_FILE_CHOOSER_ACTION_OPEN</property>- <property name="local_only">True</property>- <property name="select_multiple">False</property>- <property name="show_hidden">False</property>- <property name="do_overwrite_confirmation">False</property>- <property name="type">GTK_WINDOW_TOPLEVEL</property>- <property name="window_position">GTK_WIN_POS_NONE</property>- <property name="modal">False</property>- <property name="resizable">True</property>- <property name="destroy_with_parent">False</property>- <property name="decorated">True</property>- <property name="skip_taskbar_hint">False</property>- <property name="skip_pager_hint">False</property>- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>- <property name="focus_on_map">True</property>- <property name="urgency_hint">False</property>-- <child internal-child="vbox">- <widget class="GtkVBox" id="dialog-vbox1">- <property name="visible">True</property>- <property name="homogeneous">False</property>- <property name="spacing">24</property>-- <child internal-child="action_area">- <widget class="GtkHButtonBox" id="dialog-action_area1">- <property name="visible">True</property>- <property name="layout_style">GTK_BUTTONBOX_END</property>-- <child>- <widget class="GtkButton" id="button1">- <property name="visible">True</property>- <property name="can_default">True</property>- <property name="can_focus">True</property>- <property name="label">gtk-cancel</property>- <property name="use_stock">True</property>- <property name="relief">GTK_RELIEF_NORMAL</property>- <property name="focus_on_click">True</property>- <property name="response_id">-6</property>- </widget>- </child>-- <child>- <widget class="GtkButton" id="opendialog-Open-button">- <property name="visible">True</property>- <property name="can_default">True</property>- <property name="has_default">True</property>- <property name="can_focus">True</property>- <property name="label">gtk-open</property>- <property name="use_stock">True</property>- <property name="relief">GTK_RELIEF_NORMAL</property>- <property name="focus_on_click">True</property>- <property name="response_id">-5</property>- </widget>- </child>- </widget>- <packing>- <property name="padding">0</property>- <property name="expand">False</property>- <property name="fill">True</property>- <property name="pack_type">GTK_PACK_END</property>- </packing>- </child>- </widget>- </child>-</widget>--<widget class="GtkFileChooserDialog" id="savedialog">- <property name="action">GTK_FILE_CHOOSER_ACTION_SAVE</property>- <property name="local_only">True</property>- <property name="select_multiple">False</property>- <property name="show_hidden">False</property>- <property name="do_overwrite_confirmation">False</property>- <property name="type">GTK_WINDOW_TOPLEVEL</property>- <property name="window_position">GTK_WIN_POS_NONE</property>- <property name="modal">False</property>- <property name="resizable">True</property>- <property name="destroy_with_parent">False</property>- <property name="decorated">True</property>- <property name="skip_taskbar_hint">False</property>- <property name="skip_pager_hint">False</property>- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>- <property name="focus_on_map">True</property>- <property name="urgency_hint">False</property>-- <child internal-child="vbox">- <widget class="GtkVBox" id="dialog-vbox2">- <property name="visible">True</property>- <property name="homogeneous">False</property>- <property name="spacing">24</property>-- <child internal-child="action_area">- <widget class="GtkHButtonBox" id="dialog-action_area2">- <property name="visible">True</property>- <property name="layout_style">GTK_BUTTONBOX_END</property>-- <child>- <widget class="GtkButton" id="button2">- <property name="visible">True</property>- <property name="can_default">True</property>- <property name="can_focus">True</property>- <property name="label">gtk-cancel</property>- <property name="use_stock">True</property>- <property name="relief">GTK_RELIEF_NORMAL</property>- <property name="focus_on_click">True</property>- <property name="response_id">-6</property>- </widget>- </child>-- <child>- <widget class="GtkButton" id="button3">- <property name="visible">True</property>- <property name="can_default">True</property>- <property name="has_default">True</property>- <property name="can_focus">True</property>- <property name="label">gtk-save</property>- <property name="use_stock">True</property>- <property name="relief">GTK_RELIEF_NORMAL</property>- <property name="focus_on_click">True</property>- <property name="response_id">-5</property>- </widget>- </child>- </widget>- <packing>- <property name="padding">0</property>- <property name="expand">False</property>- <property name="fill">True</property>- <property name="pack_type">GTK_PACK_END</property>- </packing>- </child>- </widget>- </child>-</widget>--</glade-interface>
+ data/main.ui view
@@ -0,0 +1,318 @@+<?xml version="1.0"?>+<!--*- mode: xml -*-->+<interface>+ <object class="GtkUIManager" id="uimanager1">+ <child>+ <object class="GtkActionGroup" id="actiongroup1">+ <child>+ <object class="GtkAction" id="menuitem1">+ <property name="name">menuitem1</property>+ <property name="label" translatable="yes">_File</property>+ </object>+ </child>+ <child>+ <object class="GtkAction" id="new1">+ <property name="stock_id">gtk-new</property>+ <property name="name">new1</property>+ <signal handler="on_new1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT" name="activate"/>+ </object>+ </child>+ <child>+ <object class="GtkAction" id="open1">+ <property name="stock_id">gtk-open</property>+ <property name="name">open1</property>+ <signal handler="on_open1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT" name="activate"/>+ </object>+ </child>+ <child>+ <object class="GtkAction" id="save1">+ <property name="stock_id">gtk-save</property>+ <property name="name">save1</property>+ <signal handler="on_save1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT" name="activate"/>+ </object>+ </child>+ <child>+ <object class="GtkAction" id="save_as1">+ <property name="stock_id">gtk-save-as</property>+ <property name="name">save_as1</property>+ <signal handler="on_save_as1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT" name="activate"/>+ </object>+ </child>+ <child>+ <object class="GtkAction" id="quit1">+ <property name="stock_id">gtk-quit</property>+ <property name="name">quit1</property>+ <signal handler="on_quit1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT" name="activate"/>+ </object>+ </child>+ <child>+ <object class="GtkAction" id="menuitem2">+ <property name="name">menuitem2</property>+ <property name="label" translatable="yes">_Edit</property>+ </object>+ </child>+ <child>+ <object class="GtkAction" id="cut1">+ <property name="stock_id">gtk-cut</property>+ <property name="name">cut1</property>+ <signal handler="on_cut1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT" name="activate"/>+ </object>+ </child>+ <child>+ <object class="GtkAction" id="copy1">+ <property name="stock_id">gtk-copy</property>+ <property name="name">copy1</property>+ <signal handler="on_copy1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT" name="activate"/>+ </object>+ </child>+ <child>+ <object class="GtkAction" id="paste1">+ <property name="stock_id">gtk-paste</property>+ <property name="name">paste1</property>+ <signal handler="on_paste1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT" name="activate"/>+ </object>+ </child>+ <child>+ <object class="GtkAction" id="delete1">+ <property name="stock_id">gtk-delete</property>+ <property name="name">delete1</property>+ <signal handler="on_delete1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT" name="activate"/>+ </object>+ </child>+ <child>+ <object class="GtkAction" id="menuitem3">+ <property name="name">menuitem3</property>+ <property name="label" translatable="yes">_View</property>+ </object>+ </child>+ <child>+ <object class="GtkAction" id="menuitem4">+ <property name="name">menuitem4</property>+ <property name="label" translatable="yes">_Help</property>+ </object>+ </child>+ <child>+ <object class="GtkAction" id="about1">+ <property name="name">about1</property>+ <property name="label" translatable="yes">_About</property>+ <signal handler="on_about1_activate" last_modification_time="Sat, 05 Aug 2006 08:27:01 GMT" name="activate"/>+ </object>+ </child>+ </object>+ </child>+ <ui>+ <menubar name="menubar1">+ <menu action="menuitem1">+ <menuitem action="new1"/>+ <menuitem action="open1"/>+ <menuitem action="save1"/>+ <menuitem action="save_as1"/>+ <separator/>+ <menuitem action="quit1"/>+ </menu>+ <menu action="menuitem2">+ <menuitem action="cut1"/>+ <menuitem action="copy1"/>+ <menuitem action="paste1"/>+ <menuitem action="delete1"/>+ </menu>+ <menu action="menuitem3"/>+ <menu action="menuitem4">+ <menuitem action="about1"/>+ </menu>+ </menubar>+ </ui>+ </object>+ <object class="GtkWindow" id="window1">+ <property name="visible">True</property>+ <property name="title" translatable="yes">window1</property>+ <property name="type">GTK_WINDOW_TOPLEVEL</property>+ <property name="window_position">GTK_WIN_POS_NONE</property>+ <property name="modal">False</property>+ <property name="resizable">True</property>+ <property name="destroy_with_parent">False</property>+ <property name="decorated">True</property>+ <property name="skip_taskbar_hint">False</property>+ <property name="skip_pager_hint">False</property>+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>+ <property name="focus_on_map">True</property>+ <property name="urgency_hint">False</property>+ <child>+ <object class="GtkVBox" id="vbox1">+ <property name="visible">True</property>+ <property name="homogeneous">False</property>+ <property name="spacing">0</property>+ <child>+ <object class="GtkMenuBar" constructor="uimanager1" id="menubar1">+ <property name="visible">True</property>+ <property name="pack_direction">GTK_PACK_DIRECTION_LTR</property>+ <property name="child_pack_direction">GTK_PACK_DIRECTION_LTR</property>+ </object>+ <packing>+ <property name="padding">0</property>+ <property name="expand">False</property>+ <property name="fill">False</property>+ </packing>+ </child>+ <child>+ <object class="GtkDrawingArea" id="drawingarea1">+ <property name="visible">True</property>+ </object>+ <packing>+ <property name="padding">0</property>+ <property name="expand">True</property>+ <property name="fill">True</property>+ </packing>+ </child>+ <child>+ <object class="GtkStatusbar" id="statusbar1">+ <property name="visible">True</property>+ <property name="has_resize_grip">True</property>+ </object>+ <packing>+ <property name="padding">0</property>+ <property name="expand">False</property>+ <property name="fill">False</property>+ </packing>+ </child>+ </object>+ </child>+ </object>+ <object class="GtkAboutDialog" id="aboutdialog1">+ <property name="destroy_with_parent">False</property>+ <property name="name" translatable="yes">Application Name</property>+ <property name="wrap_license">False</property>+ <property comments="TRANSLATORS: Replace this string with your names, one name per line." name="translator_credits" translatable="yes">translator-credits</property>+ </object>+ <object class="GtkFileChooserDialog" id="opendialog">+ <property name="action">GTK_FILE_CHOOSER_ACTION_OPEN</property>+ <property name="local_only">True</property>+ <property name="select_multiple">False</property>+ <property name="show_hidden">False</property>+ <property name="do_overwrite_confirmation">False</property>+ <property name="type">GTK_WINDOW_TOPLEVEL</property>+ <property name="window_position">GTK_WIN_POS_NONE</property>+ <property name="modal">False</property>+ <property name="resizable">True</property>+ <property name="destroy_with_parent">False</property>+ <property name="decorated">True</property>+ <property name="skip_taskbar_hint">False</property>+ <property name="skip_pager_hint">False</property>+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>+ <property name="focus_on_map">True</property>+ <property name="urgency_hint">False</property>+ <child internal-child="vbox">+ <object class="GtkVBox" id="dialog-vbox1">+ <property name="visible">True</property>+ <property name="homogeneous">False</property>+ <property name="spacing">24</property>+ <child internal-child="action_area">+ <object class="GtkHButtonBox" id="dialog-action_area1">+ <property name="visible">True</property>+ <property name="layout_style">GTK_BUTTONBOX_END</property>+ <child>+ <object class="GtkButton" id="button1">+ <property name="visible">True</property>+ <property name="can_default">True</property>+ <property name="can_focus">True</property>+ <property name="label">gtk-cancel</property>+ <property name="use_stock">True</property>+ <property name="relief">GTK_RELIEF_NORMAL</property>+ <property name="focus_on_click">True</property>+ </object>+ </child>+ <child>+ <object class="GtkButton" id="opendialog-Open-button">+ <property name="visible">True</property>+ <property name="can_default">True</property>+ <property name="has_default">True</property>+ <property name="can_focus">True</property>+ <property name="label">gtk-open</property>+ <property name="use_stock">True</property>+ <property name="relief">GTK_RELIEF_NORMAL</property>+ <property name="focus_on_click">True</property>+ </object>+ </child>+ </object>+ <packing>+ <property name="padding">0</property>+ <property name="expand">False</property>+ <property name="fill">True</property>+ <property name="pack_type">GTK_PACK_END</property>+ </packing>+ </child>+ </object>+ </child>+ <action-widgets>+ <action-widget response="-6">button1</action-widget>+ <action-widget response="-5">opendialog-Open-button</action-widget>+ </action-widgets>+ </object>+ <object class="GtkFileChooserDialog" id="savedialog">+ <property name="action">GTK_FILE_CHOOSER_ACTION_SAVE</property>+ <property name="local_only">True</property>+ <property name="select_multiple">False</property>+ <property name="show_hidden">False</property>+ <property name="do_overwrite_confirmation">False</property>+ <property name="type">GTK_WINDOW_TOPLEVEL</property>+ <property name="window_position">GTK_WIN_POS_NONE</property>+ <property name="modal">False</property>+ <property name="resizable">True</property>+ <property name="destroy_with_parent">False</property>+ <property name="decorated">True</property>+ <property name="skip_taskbar_hint">False</property>+ <property name="skip_pager_hint">False</property>+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>+ <property name="focus_on_map">True</property>+ <property name="urgency_hint">False</property>+ <child internal-child="vbox">+ <object class="GtkVBox" id="dialog-vbox2">+ <property name="visible">True</property>+ <property name="homogeneous">False</property>+ <property name="spacing">24</property>+ <child internal-child="action_area">+ <object class="GtkHButtonBox" id="dialog-action_area2">+ <property name="visible">True</property>+ <property name="layout_style">GTK_BUTTONBOX_END</property>+ <child>+ <object class="GtkButton" id="button2">+ <property name="visible">True</property>+ <property name="can_default">True</property>+ <property name="can_focus">True</property>+ <property name="label">gtk-cancel</property>+ <property name="use_stock">True</property>+ <property name="relief">GTK_RELIEF_NORMAL</property>+ <property name="focus_on_click">True</property>+ </object>+ </child>+ <child>+ <object class="GtkButton" id="button3">+ <property name="visible">True</property>+ <property name="can_default">True</property>+ <property name="has_default">True</property>+ <property name="can_focus">True</property>+ <property name="label">gtk-save</property>+ <property name="use_stock">True</property>+ <property name="relief">GTK_RELIEF_NORMAL</property>+ <property name="focus_on_click">True</property>+ </object>+ </child>+ </object>+ <packing>+ <property name="padding">0</property>+ <property name="expand">False</property>+ <property name="fill">True</property>+ <property name="pack_type">GTK_PACK_END</property>+ </packing>+ </child>+ </object>+ </child>+ <action-widgets>+ <action-widget response="-6">button2</action-widget>+ <action-widget response="-5">button3</action-widget>+ </action-widgets>+ </object>+</interface>
src/cairo-appbase.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE RankNTypes #-} {-# OPTIONS -Wall #-} -- -- Based on Gtk2Hs/demo/cairo/Drawing2.hs @@ -7,9 +8,7 @@ -- import Control.Monad (replicateM_)-import qualified System.Glib.Types as GTypes import qualified Graphics.UI.Gtk as G-import qualified Graphics.UI.Gtk.Glade as Glade import qualified Graphics.Rendering.Cairo as C import qualified Graphics.Rendering.Cairo.Matrix as M @@ -33,50 +32,56 @@ main = do _ <- G.initGUI - -- load up the glade file- filename <- My.getDataFileName "data/main.glade"- windowXmlM <- Glade.xmlNew filename+ -- load up the gtk-builder file+ filename <- My.getDataFileName "data/main.ui"+ builder <- G.builderNew+ G.builderAddFromFile builder filename+{- let windowXml = case windowXmlM of (Just wX) -> wX Nothing -> error ("can't find the glade file " ++ filename)- get :: (G.WidgetClass widget) => (GTypes.GObject -> widget) -> String -> IO widget- get = Glade.xmlGetWidget windowXml+-}+ let get :: forall cls . G.GObjectClass cls+ => (G.GObject -> cls)+ -> String+ -> IO cls+ get = G.builderGetObject builder -- get a handle on widgets from the glade file window <- get G.castToWindow "window1" -- set up File->New- new1 <- get G.castToMenuItem "new1"- _ <- G.onActivateLeaf new1 $ myNew+ new1 <- get G.castToAction "new1"+ _ <- G.onActionActivate new1 $ myNew -- set up the File->Open dialog- open1 <- get G.castToMenuItem "open1"+ open1 <- get G.castToAction "open1" openDialog <- get G.castToFileChooserDialog "opendialog"- _ <- G.onActivateLeaf open1 $ G.widgetShow openDialog+ _ <- G.onActionActivate open1 $ G.widgetShow openDialog _ <- G.onResponse openDialog $ myFileOpen openDialog -- set up the File->Save_As dialog- save1 <- get G.castToMenuItem "save1"- save_as1 <- get G.castToMenuItem "save_as1"+ save1 <- get G.castToAction "save1"+ save_as1 <- get G.castToAction "save_as1" saveDialog <- get G.castToFileChooserDialog "savedialog"- _ <- G.onActivateLeaf save_as1 $ G.widgetShow saveDialog- _ <- G.onActivateLeaf save1 $ G.widgetShow saveDialog+ _ <- G.onActionActivate save_as1 $ G.widgetShow saveDialog+ _ <- G.onActionActivate save1 $ G.widgetShow saveDialog _ <- G.onResponse saveDialog $ myFileSave saveDialog -- set up Edit menu- cut1 <- get G.castToMenuItem "cut1"- _ <- G.onActivateLeaf cut1 $ myCut- copy1 <- get G.castToMenuItem "copy1"- _ <- G.onActivateLeaf copy1 $ myCopy- paste1 <- get G.castToMenuItem "paste1"- _ <- G.onActivateLeaf paste1 $ myPaste- delete1 <- get G.castToMenuItem "delete1"- _ <- G.onActivateLeaf delete1 $ myDelete+ cut1 <- get G.castToAction "cut1"+ _ <- G.onActionActivate cut1 $ myCut+ copy1 <- get G.castToAction "copy1"+ _ <- G.onActionActivate copy1 $ myCopy+ paste1 <- get G.castToAction "paste1"+ _ <- G.onActionActivate paste1 $ myPaste+ delete1 <- get G.castToAction "delete1"+ _ <- G.onActionActivate delete1 $ myDelete -- set up the Help->About dialog- about1 <- get G.castToMenuItem "about1"+ about1 <- get G.castToAction "about1" aboutdialog1 <- get G.castToAboutDialog "aboutdialog1"- _ <- G.onActivateLeaf about1 $ G.widgetShow aboutdialog1+ _ <- G.onActionActivate about1 $ G.widgetShow aboutdialog1 _ <- G.onResponse aboutdialog1 $ const $ G.widgetHide aboutdialog1 -- fix size@@ -84,8 +89,8 @@ G.widgetSetSizeRequest window windowWidth windowHeight -- quit on File->Quit menu selection- quit1 <- get G.castToMenuItem "quit1"- _ <- G.onActivateLeaf quit1 $ G.widgetDestroy window+ quit1 <- get G.castToAction "quit1"+ _ <- G.onActionActivate quit1 $ G.widgetDestroy window _ <- G.onDestroy window G.mainQuit -- set up the canvas