bakery  2.6
App_Gtk.h
Go to the documentation of this file.
1 /*
2  * Copyright 2000 Murray Cumming
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the Free
16  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18 
19 #ifndef BAKERY_APP_GTK_H
20 #define BAKERY_APP_GTK_H
21 
22 #include <bakeryconfig.h> // For BAKERY_MAEMO_ENABLED
23 #include <bakery/App/App.h>
24 
25 #ifdef BAKERY_MAEMO_ENABLED
26 #include <hildonmm/window.h>
27 #endif
28 
29 #include <gtkmm/menubar.h>
30 #include <gtkmm/menu.h>
31 #include <gtkmm/toolbar.h>
32 #include <gtkmm/handlebox.h>
33 #include <gtkmm/dialog.h>
34 #include <gtkmm/uimanager.h>
35 #include <libglademm.h>
36 
37 namespace Bakery
38 {
39 
46 class App_Gtk
47  : virtual public App, //virtual because App_WithDoc_Gtk will inherit it via App_Gtk and via App_With_Doc
48 #ifdef BAKERY_MAEMO_ENABLED
49  virtual public Hildon::Window //inherit virtually to share sigc::trackable.
50 #else
51  virtual public Gtk::Window //inherit virtually to share sigc::trackable.
52 #endif
53 {
54 public:
55 #ifdef BAKERY_MAEMO_ENABLED
56  typedef Hildon::Window ParentWindow;
57 #else
58  typedef Gtk::Window ParentWindow;
59 #endif
60  friend class AppInstanceManager;
61 
63  App_Gtk(const Glib::ustring& appname);
64 
66  App_Gtk(BaseObjectType* cobject, const Glib::ustring& appname);
67 
68  virtual ~App_Gtk();
69 
71  virtual void add(Gtk::Widget& child);
72 
74  static Glib::ustring util_bold_message(const Glib::ustring& message);
75 
76 protected:
77 
78  virtual void init(); //Override to show().
79  virtual void init_ui_manager(); //Override this to add more UI placeholders
80  virtual void init_menus(); //Override this to add more or different menus.
81  virtual void init_menus_file(); //Call this from init_menus() to add the standard file menu.
82  virtual void init_menus_edit(); //Call this from init_menus() to add the standard edit menu
83  virtual void init_menus_help(); //Call this from init_menus() to add the standard help menu.
84  virtual void init_toolbars();
85 
86  virtual void init_layout(); //Arranges the menu, toolbar, etc.
87 
88  virtual void add_ui_from_string(const Glib::ustring& ui_description); //Convenience function
89 
90  virtual void on_hide(); //override.
91 
92  //Signal handlers:
93 
94  //Menus:
95  virtual void on_menu_help_about();
96 
97  virtual void on_about_close();
98 
99 
100  virtual void ui_hide();
101  virtual void ui_bring_to_front();
102 
103  virtual bool on_delete_event(GdkEventAny* event); //override
104 
105  //virtual void destroy_and_remove_from_list();
106 
107  //Member data:
108 
109  //UIManager and Actions
110  Glib::RefPtr<Gtk::UIManager> m_refUIManager;
111  Glib::RefPtr<Gtk::ActionGroup> m_refFileActionGroup;
112  Glib::RefPtr<Gtk::ActionGroup> m_refEditActionGroup;
113  Glib::RefPtr<Gtk::ActionGroup> m_refHelpActionGroup;
114 
115  //Member widgets:
116  Gtk::VBox* m_pVBox;
118 
119  //Gtk::MenuBar m_MenuBar;
120  //Gtk::Menu m_Menu_File, m_Menu_Edit, m_Menu_Help;
121 
122  Gtk::HandleBox m_HandleBox_Toolbar;
123  //Gtk::Toolbar m_Toolbar;
124 
125  //All instances share 1 About box:
126  static Gtk::Window* m_pAbout; //About box.
127 
128 
129  //typedef std::vector<poptOption> type_vecPoptOptions;
130  //type_vecPoptOptions m_vecPoptOptions;
131 };
132 
133 } //namespace
134 
135 #endif //BAKERY_APP_GTK_H
static Glib::ustring util_bold_message(const Glib::ustring &message)
For instance, to create bold primary text for a dialog box, without marking the markup for translatio...
virtual void init_menus_edit()
Call this from init_menus() to add the standard edit menu.
virtual void init_menus_file()
Call this from init_menus() to add the standard file menu.
Glib::RefPtr< Gtk::ActionGroup > m_refHelpActionGroup
Definition: App_Gtk.h:113
virtual void init_toolbars()
virtual void init_ui_manager()
Builds the intial ui string, with placeholders.
virtual void on_hide()
virtual ~App_Gtk()
Gtk::VBox m_VBox_PlaceHolder
Definition: App_Gtk.h:117
virtual void on_menu_help_about()
virtual void init_menus()
Override this to add more menus or different menus.
Gtk::VBox * m_pVBox
Definition: App_Gtk.h:116
virtual bool on_delete_event(GdkEventAny *event)
virtual void init_layout()
virtual void add(Gtk::Widget &child)
Overidden to add a widget in the middle, under the menu, instead of replacing the whole contents...
Definition: App.h:29
App_Gtk(const Glib::ustring &appname)
Don't forget to call init() too.
Bakery's Main Window.
Definition: App.h:60
virtual void init()
Gtk::HandleBox m_HandleBox_Toolbar
Definition: App_Gtk.h:122
virtual void init_menus_help()
Call this from init_menus() to add the standard help menu.
Glib::RefPtr< Gtk::UIManager > m_refUIManager
Definition: App_Gtk.h:110
virtual void on_about_close()
Glib::RefPtr< Gtk::ActionGroup > m_refEditActionGroup
Definition: App_Gtk.h:112
Glib::RefPtr< Gtk::ActionGroup > m_refFileActionGroup
Definition: App_Gtk.h:111
Contains a list of App instances.
Definition: AppInstanceManager.h:36
virtual void ui_bring_to_front()
Gtk::Window ParentWindow
Definition: App_Gtk.h:58
virtual void add_ui_from_string(const Glib::ustring &ui_description)
virtual void ui_hide()
static Gtk::Window * m_pAbout
Definition: App_Gtk.h:126
This class implements Bakery::App using gtkmm.
Definition: App_Gtk.h:46