Ignore:
Timestamp:
29/06/10 14:33:31 (3 years ago)
Author:
Matias De la Puente <mfpuente.ar@…>
Children:
a3d57aae7735bdde7300b1e663df36ade9dc8e8c
Parents:
466127d49214489bb79e36b257c34f9f634f2adb
git-committer:
Matias De la Puente <mfpuente.ar@…> (29/06/10 14:33:31)
Message:

Programmers: Move actions to the menu and toolbar

Fixes Ticket #2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libi4uc/i4ucprogrammersview.vala

    r3c2306a rf7ca2a2  
    2323public class I4uc.ProgrammersView : GLib.Object, ProgrammersViewIface 
    2424{ 
     25        private UIManager _ui_manager; 
     26        private ActionGroup _action_group; 
    2527        private PagesPanel _pages_panel; 
    2628        private SidePanel _side_panel; 
     
    2830        private ProgrammersSidePage _side_page = new ProgrammersSidePage (); 
    2931        private LogPage _log_page = new LogPage (_("Message")); 
     32        private Action _write_flash_action; 
     33        private Action _read_flash_action; 
     34        private Action _verify_flash_action; 
     35        private Action _erase_flash_action; 
     36        private Action _write_fuses_action; 
     37        private Action _read_fuses_action; 
     38        private Action _get_version_action; 
     39        private Action _stop_action; 
    3040         
    3141        public PagesPanelIface pages_panel { get { return _pages_panel; } } 
     
    3343        public LogPageIface log_page { get { return _log_page; } } 
    3444         
    35         public ProgrammersView (PagesPanel pages_panel, SidePanel side_panel, BottomPanel bottom_panel) 
    36         { 
     45        public bool write_flash_sensitive 
     46        { 
     47                set { _write_flash_action.sensitive = value; } 
     48                get { return _write_flash_action.sensitive; } 
     49        } 
     50         
     51        public bool read_flash_sensitive 
     52        { 
     53                set { _read_flash_action.sensitive = value; } 
     54                get { return _read_flash_action.sensitive; } 
     55        } 
     56         
     57        public bool verify_flash_sensitive 
     58        { 
     59                set { _verify_flash_action.sensitive = value; } 
     60                get { return _verify_flash_action.sensitive; } 
     61        } 
     62         
     63        public bool erase_flash_sensitive 
     64        { 
     65                set { _erase_flash_action.sensitive = value; } 
     66                get { return _erase_flash_action.sensitive; } 
     67        } 
     68         
     69        public bool write_fuses_sensitive 
     70        { 
     71                set { _write_fuses_action.sensitive = value; } 
     72                get { return _write_fuses_action.sensitive; } 
     73        } 
     74         
     75        public bool read_fuses_sensitive 
     76        { 
     77                set { _read_fuses_action.sensitive = value; } 
     78                get { return _read_fuses_action.sensitive; } 
     79        } 
     80         
     81        public bool get_version_sensitive 
     82        { 
     83                set { _get_version_action.sensitive = value; } 
     84                get { return _get_version_action.sensitive; } 
     85        } 
     86         
     87        public bool stop_sensitive 
     88        { 
     89                set { _stop_action.sensitive = value; } 
     90                get { return _stop_action.sensitive; } 
     91        } 
     92         
     93        public ProgrammersView (UIManager ui_manager, PagesPanel pages_panel, SidePanel side_panel, BottomPanel bottom_panel) 
     94        { 
     95                _ui_manager = ui_manager; 
    3796                _pages_panel = pages_panel; 
    3897                _side_panel = side_panel; 
    3998                _bottom_panel = bottom_panel; 
     99                 
     100                _action_group = new ActionGroup ("I4ucProgrammersActions"); 
     101                _action_group.set_translation_domain (Config.GETTEXT_PACKAGE); 
     102                _action_group.add_actions (_action_entries, this); 
     103                 
     104                _ui_manager.insert_action_group (_action_group, -1); 
     105                 
     106                try 
     107                { 
     108                        _ui_manager.add_ui_from_string (_UI, -1); 
     109                } 
     110                catch (GLib.Error e) 
     111                { 
     112                        warning (e.message); 
     113                } 
     114                 
     115                _write_flash_action = _action_group.get_action ("WriteFlashProgrammerAction"); 
     116                _read_flash_action = _action_group.get_action ("ReadFlashProgrammerAction"); 
     117                _verify_flash_action = _action_group.get_action ("VerifyFlashProgrammerAction"); 
     118                _erase_flash_action = _action_group.get_action ("EraseFlashProgrammerAction"); 
     119                _write_fuses_action = _action_group.get_action ("WriteFusesProgrammerAction"); 
     120                _read_fuses_action = _action_group.get_action ("ReadFusesProgrammerAction"); 
     121                _get_version_action = _action_group.get_action ("GetVersionProgrammerAction"); 
     122                _stop_action = _action_group.get_action ("StopProgrammerAction"); 
     123                 
     124                var toolbar = (Toolbar)_ui_manager.get_widget ("/MainToolbar"); 
     125                Gtk.Callback non_homogeneous = (item) => { ((ToolItem)item).set_homogeneous (false); }; 
     126                toolbar.foreach (non_homogeneous); 
    40127                 
    41128                _side_panel.insert_page (_side_page, 1); 
     
    81168                dialog.destroy (); 
    82169        } 
     170         
     171        public void on_write_flash () 
     172        { 
     173                this.write_flash_clicked (); 
     174        } 
     175         
     176        public void on_read_flash () 
     177        { 
     178                this.read_flash_clicked (); 
     179        } 
     180         
     181        public void on_verify_flash () 
     182        { 
     183                this.verify_flash_clicked (); 
     184        } 
     185         
     186        public void on_erase_flash () 
     187        { 
     188                this.erase_flash_clicked (); 
     189        } 
     190         
     191        public void on_write_fuses () 
     192        { 
     193                this.write_fuses_clicked (); 
     194        } 
     195         
     196        public void on_read_fuses () 
     197        { 
     198                this.read_fuses_clicked (); 
     199        } 
     200         
     201        public void on_get_version () 
     202        { 
     203                this.get_version_clicked (); 
     204        } 
     205         
     206        public void on_stop () 
     207        { 
     208                this.stop_clicked (); 
     209        } 
     210         
     211        private const ActionEntry[] _action_entries = 
     212        { 
     213                { "ProgrammersMenuAction", null, N_("_Programmers") }, 
     214                { "WriteFlashProgrammerAction", "i4uc-write-flash", N_("Write flash"), null, N_("Write to flash memory"), on_write_flash }, 
     215                { "ReadFlashProgrammerAction", "i4uc-read-flash", N_("Read flash"), null, N_("Read flash memory"), on_read_flash }, 
     216                { "VerifyFlashProgrammerAction", "i4uc-verify-flash", N_("Verify flash"), null, N_("Verify flash memory"), on_verify_flash }, 
     217                { "EraseFlashProgrammerAction", "i4uc-erase-flash", N_("Erase flash"), null, N_("Erase flash memory"), on_erase_flash }, 
     218                { "WriteFusesProgrammerAction", null, N_("Write fuses"), null, N_("Write fuses"), on_write_fuses }, 
     219                { "ReadFusesProgrammerAction", null, N_("Read fuses"), null, N_("Read fuses"), on_read_fuses }, 
     220                { "GetVersionProgrammerAction", null, N_("Get version"), null, N_("Get version of programmer"), on_get_version }, 
     221                { "StopProgrammerAction", STOCK_STOP, N_("Stop"), "", N_("Stop programmer action"), on_stop } 
     222        }; 
     223         
     224        private const string _UI = """ 
     225<ui> 
     226        <menubar name="MainMenu"> 
     227                <placeholder name="MenuBarOps"> 
     228                        <menu name="ProgrammersMenu" action="ProgrammersMenuAction"> 
     229                                <menuitem action="WriteFlashProgrammerAction"/> 
     230                                <menuitem action="ReadFlashProgrammerAction"/> 
     231                                <menuitem action="VerifyFlashProgrammerAction"/> 
     232                                <menuitem action="EraseFlashProgrammerAction"/> 
     233                                <menuitem action="WriteFusesProgrammerAction"/> 
     234                                <menuitem action="ReadFusesProgrammerAction"/> 
     235                                <menuitem action="GetVersionProgrammerAction"/> 
     236                                <menuitem action="StopProgrammerAction"/> 
     237                        </menu> 
     238                </placeholder> 
     239        </menubar> 
     240        <toolbar name="MainToolbar"> 
     241                <placeholder name="ToolbarEndOps"> 
     242                        <separator/> 
     243                                <toolitem action="WriteFlashProgrammerAction"/> 
     244                                <toolitem action="ReadFlashProgrammerAction"/> 
     245                                <toolitem action="VerifyFlashProgrammerAction"/> 
     246                                <toolitem action="EraseFlashProgrammerAction"/> 
     247                                <toolitem action="StopProgrammerAction"/> 
     248                        <separator/> 
     249                </placeholder> 
     250        </toolbar> 
     251</ui>"""; 
    83252} 
Note: See TracChangeset for help on using the changeset viewer.