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