]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/Menubar_pimpl.h
Dekel's lyxrc.example; Angus's FormDocument; John's build-listerrors; POTFILES.in...
[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 "LString.h"
20 #include <gnome--/app.h>
21 #include "frontends/Menubar.h"
22 #include "commandtags.h"
23 #include "buffer.h"
24
25 class LyXView;
26 class MenuBackend;
27 class MenuItem;
28 class StrPool;
29
30 #ifdef SIGC_CXX_NAMESPACES
31 using SigC::Connection;
32 #endif
33
34 #include "debug.h"
35
36 /*
37   Structure containing Gtk widget and corresponding LyX action
38 */
39 struct GtkWidgetToAction
40 {
41 public:
42   GtkWidgetToAction(GtkWidget * w, int a) { widget_=w; action_=a; }
43   
44 public:
45   GtkWidget * widget_;
46   int action_;
47 };
48
49 /** The LyX GUI independent menubar class
50   The GUI interface is implemented in the corresponding Menubar_pimpl class. 
51   */
52 class Menubar::Pimpl: public SigC::Object {
53 public:
54   ///
55   Pimpl(LyXView *, MenuBackend const &);
56   ///
57   ~Pimpl();
58   ///
59   void set(string const &);
60   /// Opens a top-level submenu given its name
61   void openByName(string const &);
62   /// update the state of menuitems
63   void update();
64   /// update TOC, LOF, ... on user' request
65   void updateAllLists();
66   
67 protected:
68   /// callback function
69   void callback(int action);
70   /// callback function used by lists
71   void callbackToc(Buffer::TocItem tg);
72   /// compose Gnome::UI::Array object describing the menu
73   void composeUIInfo(string const & menu_name, vector<Gnome::UI::Info> & Menus, string path);
74   /// compose Gnome::UI::Array object describing the TOClist
75   vector<Buffer::TocItem>::const_iterator
76   composeTocUIInfo(vector<Gnome::UI::Info> & menu,
77                    vector<Buffer::TocItem> const & toclist,
78                    vector<Buffer::TocItem>::const_iterator begin,
79                    int mylevel);
80   /// populate wid_act_ vector with all widgets and corresponding actions
81   void connectWidgetToAction(GnomeUIInfo * guinfo);
82
83   /// lists (toc, lof, lot, loa)
84   struct ListsHolder {
85     string path;
86     Gnome::UI::Array lst;
87
88     ListsHolder () { }
89     ListsHolder (const ListsHolder & a) { path = a.path; lst = a.lst; }
90   };
91   /// populate lists
92   void updateList(vector<Buffer::TocItem> *, vector<ListsHolder> *);
93   /// Add to "Menus" the list of exportable/viewable formats
94   void add_formats(vector<Gnome::UI::Info> & Menus, kb_action action, bool viewable);
95   
96 private:
97   /// 
98   LyXView * owner_;
99   ///
100   MenuBackend const * menubackend_;
101   ///
102   string current_menu_name_;
103   Gnome::UI::Array Menu_;
104
105   ///
106   bool ignore_action_;
107   int  action_;
108   vector<GtkWidgetToAction> wid_act_;
109
110   /// toc
111   Connection utoc_;
112   vector<ListsHolder> toc_;
113 };
114 #endif