]>
Dogcows Code - chaz/tint2/blob - src/tint2conf/mainwin.cpp
2 #include <gtkmm/stock.h>
9 set_title ( "Tint2 config" );
10 set_default_size ( 600 , 350 );
12 add ( m_Box
); // put a MenuBar at the top of the box and other stuff below it.
14 //Create actions for menus and toolbars:
15 m_refActionGroup
= Gtk :: ActionGroup :: create ();
18 m_refActionGroup
-> add ( Gtk :: Action :: create ( "FileMenu" , "File" ));
20 m_refActionGroup
-> add ( Gtk :: Action :: create ( "FileOpen" , Gtk :: Stock :: OPEN
, "_Open" , "Open config file" ), sigc :: mem_fun (* this , & MainWin :: on_menu_file_new_generic
));
21 m_refActionGroup
-> add ( Gtk :: Action :: create ( "FileSaveAs" , Gtk :: Stock :: SAVE_AS
, "_Save As" , "Save config as" ), sigc :: mem_fun (* this , & MainWin :: on_menu_file_new_generic
));
22 m_refActionGroup
-> add ( Gtk :: Action :: create ( "FileRefreshAll" , Gtk :: Stock :: REFRESH
, "_Refresh all" , "Refresh all config file" ), sigc :: mem_fun (* this , & MainWin :: on_menu_file_new_generic
));
23 m_refActionGroup
-> add ( Gtk :: Action :: create ( "FileQuit" , Gtk :: Stock :: QUIT
), sigc :: mem_fun (* this , & MainWin :: on_menu_file_quit
));
26 m_refActionGroup
-> add ( Gtk :: Action :: create ( "EditMenu" , "Edit" ));
27 m_refActionGroup
-> add ( Gtk :: Action :: create ( "EditProperties" , Gtk :: Stock :: PROPERTIES
, "_Properties..." , "Show properties" ), sigc :: mem_fun (* this , & MainWin :: on_menu_others
));
28 m_refActionGroup
-> add ( Gtk :: Action :: create ( "EditRename" , "_Rename..." , "Rename current config" ), sigc :: mem_fun (* this , & MainWin :: on_menu_others
));
29 m_refActionGroup
-> add ( Gtk :: Action :: create ( "EditDelete" , Gtk :: Stock :: DELETE
), sigc :: mem_fun (* this , & MainWin :: on_menu_others
));
30 m_refActionGroup
-> add ( Gtk :: Action :: create ( "EditApply" , Gtk :: Stock :: APPLY
, "_Apply" , "Apply current config" ), sigc :: mem_fun (* this , & MainWin :: on_menu_others
));
31 m_refActionGroup
-> add ( Gtk :: Action :: create ( "EditRefresh" , Gtk :: Stock :: REFRESH
), sigc :: mem_fun (* this , & MainWin :: on_menu_others
));
34 m_refActionGroup
-> add ( Gtk :: Action :: create ( "HelpMenu" , "Help" ) );
35 m_refActionGroup
-> add ( Gtk :: Action :: create ( "About" , Gtk :: Stock :: ABOUT
), sigc :: mem_fun (* this , & MainWin :: on_menu_about
) );
37 m_refUIManager
= Gtk :: UIManager :: create ();
38 m_refUIManager
-> insert_action_group ( m_refActionGroup
);
40 add_accel_group ( m_refUIManager
-> get_accel_group ());
42 //Layout the actions in a menubar and toolbar:
43 Glib :: ustring ui_info
=
45 " <menubar name='MenuBar'>"
46 " <menu action='FileMenu'>"
47 " <menuitem action='FileOpen'/>"
48 " <menuitem action='FileSaveAs'/>"
50 " <menuitem action='FileRefreshAll'/>"
52 " <menuitem action='FileQuit'/>"
54 " <menu action='EditMenu'>"
55 " <menuitem action='EditProperties'/>"
56 " <menuitem action='EditRename'/>"
58 " <menuitem action='EditDelete'/>"
60 " <menuitem action='EditRefresh'/>"
62 " <menu action='HelpMenu'>"
63 " <menuitem action='About'/>"
66 " <toolbar name='ToolBar'>"
67 " <toolitem action='FileRefreshAll'/>"
69 " <toolitem action='EditProperties'/>"
70 " <toolitem action='EditApply'/>"
74 #ifdef GLIBMM_EXCEPTIONS_ENABLED
77 m_refUIManager
-> add_ui_from_string ( ui_info
);
79 catch ( const Glib :: Error
& ex
)
81 std :: cerr
<< "building menus failed: " << ex
. what ();
84 std :: auto_ptr
< Glib :: Error
> ex
;
85 m_refUIManager
-> add_ui_from_string ( ui_info
, ex
);
88 std :: cerr
<< "building menus failed: " << ex
-> what ();
90 #endif //GLIBMM_EXCEPTIONS_ENABLED
92 //Get the menubar and toolbar widgets, and add them to a container widget:
93 Gtk :: Widget
* pMenubar
= m_refUIManager
-> get_widget ( "/MenuBar" );
95 m_Box
. pack_start (* pMenubar
, Gtk :: PACK_SHRINK
);
97 Gtk :: Widget
* pToolbar
= m_refUIManager
-> get_widget ( "/ToolBar" ) ;
99 m_Box
. pack_start (* pToolbar
, Gtk :: PACK_SHRINK
);
112 void MainWin :: on_menu_file_quit ()
118 void MainWin :: on_menu_file_new_generic ()
120 std :: cout
<< "A File|New menu item was selected." << std :: endl
;
124 void MainWin :: on_menu_others ()
126 std :: cout
<< "A menu item was selected." << std :: endl
;
130 void MainWin :: on_menu_about ()
132 Glib :: ustring message
= "tint2conf " + Glib :: ustring ( VERSION
);
133 Gtk :: MessageDialog
dialog (* this , message
);
135 dialog
. set_title ( "About tint2conf" );
136 dialog
. set_secondary_text ( "Config tool for tint2. \n\n Copyright (C) 2009 Thierry lorthiois. \n Refer to source code from Nitrogen \n by Dave Foster & Javeed Shaikh." );
This page took 0.042602 seconds and 4 git commands to generate.