]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/Menubar_pimpl.h
Clean-up of the button controller.
[lyx.git] / src / frontends / gnome / Menubar_pimpl.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  * 
5  *           LyX, The Document Processor
6  *       
7  *          Copyright 2000 The LyX Team.
8  *
9  * ====================================================== */
10
11 #ifndef MENUBAR_PIMPL_H
12 #define MENUBAR_PIMPL_H
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include <vector>
19 #include "gettext.h"
20 #include "LString.h"
21 #include <gnome--/app.h>
22 #include "frontends/Menubar.h"
23 #include "commandtags.h"
24 #include "buffer.h"
25
26 class LyXView;
27 class MenuBackend;
28 class MenuItem;
29 class StrPool;
30
31 #include "debug.h"
32
33 /*
34   Structure containing Gtk widget and corresponding LyX action
35 */
36 struct GtkWidgetToAction
37 {
38 public:
39   GtkWidgetToAction(GtkWidget * w, int a) { widget_=w; action_=a; }
40   
41 public:
42   GtkWidget * widget_;
43   int action_;
44 };
45
46 /** The LyX GUI independent menubar class
47   The GUI interface is implemented in the corresponding Menubar_pimpl class. 
48   */
49 class Menubar::Pimpl: public SigC::Object {
50 public:
51   ///
52   Pimpl(LyXView *, MenuBackend const &);
53   ///
54   ~Pimpl();
55   ///
56   void set(string const &);
57   /// Opens a top-level submenu given its name
58   void openByName(string const &);
59   /// update the state of menuitems
60   void update();
61   /// update TOC, LOF, ... on user' request
62   void updateAllLists();
63   
64 protected:
65   /// callback function
66   void callback(int action);
67   /// callback function used by lists
68   void callbackToc(Buffer::TocItem tg);
69   /// compose Gnome::UI::Array object describing the menu
70   void composeUIInfo(string const & menu_name, vector<Gnome::UI::Info> & Menus, string path);
71   /// compose Gnome::UI::Array object describing the TOClist
72   vector<Buffer::TocItem>::const_iterator
73   composeTocUIInfo(vector<Gnome::UI::Info> & menu,
74                    vector<Buffer::TocItem> const & toclist,
75                    vector<Buffer::TocItem>::const_iterator begin,
76                    int mylevel);
77   /// populate wid_act_ vector with all widgets and corresponding actions
78   void connectWidgetToAction(GnomeUIInfo * guinfo);
79
80   /// lists (toc, lof, lot, loa)
81   struct ListsHolder {
82     string path;
83     Gnome::UI::Array lst;
84
85     ListsHolder () { }
86     ListsHolder (const ListsHolder & a) { path = a.path; lst = a.lst; }
87   };
88   /// populate lists
89   void updateList(vector<Buffer::TocItem> *, vector<ListsHolder> *);
90   
91 private:
92   /// 
93   LyXView * owner_;
94   ///
95   MenuBackend const * menubackend_;
96   ///
97   string current_menu_name_;
98   Gnome::UI::Array Menu_;
99
100   ///
101   bool ignore_action_;
102   int  action_;
103   vector<GtkWidgetToAction> wid_act_;
104
105   /// toc
106   SigC::Connection utoc_;
107   vector<ListsHolder> toc_;
108 };
109 #endif