mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
first steps of gnome frontend rebirth
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3337 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
24567b9d61
commit
d062eda8e5
@ -19,7 +19,6 @@
|
||||
#include "debug.h"
|
||||
|
||||
#include <gnome--/main.h>
|
||||
#include "mainapp.h"
|
||||
#include <glade/glade.h>
|
||||
|
||||
using std::endl;
|
||||
@ -40,7 +39,6 @@ int const xforms_include_version = FL_INCLUDE_VERSION;
|
||||
|
||||
} // namespace anon
|
||||
|
||||
GLyxAppWin * mainAppWin;
|
||||
|
||||
int GUIRunTime::initApplication(int &, char * argv[])
|
||||
{
|
||||
@ -75,8 +73,6 @@ int GUIRunTime::initApplication(int &, char * argv[])
|
||||
string app_version(VERSION);
|
||||
static Gnome::Main a(app_id, app_version, 1, argv);
|
||||
glade_gnome_init(); // Initialize the glade library.
|
||||
static GLyxAppWin appWin;
|
||||
mainAppWin = &appWin;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ libgnome_la_LIBADD = \
|
||||
../xforms/FormMathsSpace.lo \
|
||||
../xforms/DropDown.lo \
|
||||
../xforms/Alert_pimpl.lo \
|
||||
../xforms/Menubar_pimpl.lo \
|
||||
@LYX_LIBS@ @FRONTEND_LDFLAGS@ @FRONTEND_LIBS@
|
||||
|
||||
# ../xforms/FileDialog.lo \
|
||||
@ -85,15 +86,17 @@ libgnome_la_SOURCES = \
|
||||
gnomeBC.h \
|
||||
GUIRunTime.C \
|
||||
pixbutton.h \
|
||||
mainapp.C \
|
||||
mainapp.h \
|
||||
Menubar_pimpl.C \
|
||||
Menubar_pimpl.h \
|
||||
support.c \
|
||||
support.h \
|
||||
Timeout_pimpl.C \
|
||||
Timeout_pimpl.h
|
||||
|
||||
# Trying to make things a litte more tidy. -- Koz-2002-01-11
|
||||
# mainapp.C \
|
||||
# mainapp.h \
|
||||
# Menubar_pimpl.C \
|
||||
# Menubar_pimpl.h \
|
||||
#
|
||||
# FormCopyright.C \
|
||||
# FormCopyright.h \
|
||||
# FormCredits.C \
|
||||
|
@ -1,413 +0,0 @@
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 2000 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include "support/lstrings.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/StrPool.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "debug.h"
|
||||
#include "LyXAction.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "kbmap.h"
|
||||
#include "bufferlist.h"
|
||||
#include "lastfiles.h"
|
||||
#include "LyXView.h"
|
||||
#include "MenuBackend.h"
|
||||
#include "Menubar_pimpl.h"
|
||||
#include "lyxtext.h"
|
||||
#include "exporter.h"
|
||||
|
||||
#include "mainapp.h"
|
||||
|
||||
#include <gtk--/menu.h>
|
||||
|
||||
using std::endl;
|
||||
|
||||
// temporary solution for LyXView
|
||||
extern GLyxAppWin * mainAppWin;
|
||||
|
||||
// Some constants
|
||||
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
||||
extern LyXAction lyxaction;
|
||||
extern BufferList bufferlist;
|
||||
extern LastFiles * lastfiles;
|
||||
|
||||
|
||||
|
||||
Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mb)
|
||||
: owner_(view), menubackend_(&mb), ignore_action_(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Menubar::Pimpl::~Pimpl()
|
||||
{
|
||||
if (utoc_.connected()) utoc_.disconnect();
|
||||
}
|
||||
|
||||
void Menubar::Pimpl::set(string const & menu_name)
|
||||
{
|
||||
// if (current_menu_name_ != menu_name) // disabled until Lastfiles and Documents are added dynamically to menu
|
||||
//{
|
||||
current_menu_name_ = menu_name;
|
||||
|
||||
// clean up the lists
|
||||
toc_.clear();
|
||||
if (utoc_.connected()) utoc_.disconnect();
|
||||
|
||||
// compose new menu
|
||||
vector<Gnome::UI::Info> menus;
|
||||
composeUIInfo(current_menu_name_, menus, "");
|
||||
|
||||
// set menu
|
||||
Menu_ = menus;
|
||||
mainAppWin->set_menu(Menu_);
|
||||
|
||||
// connect all menu items to correspoding action
|
||||
wid_act_.clear();
|
||||
ignore_action_ = true;
|
||||
connectWidgetToAction(Menu_.gtkobj());
|
||||
ignore_action_ = false;
|
||||
|
||||
// update state of the items
|
||||
update();
|
||||
updateAllLists();
|
||||
//}
|
||||
}
|
||||
|
||||
void Menubar::Pimpl::updateAllLists()
|
||||
{
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning Implement me! (be 20010324)
|
||||
#endif
|
||||
#if 0
|
||||
// update lists
|
||||
if (toc_.size() > 0)
|
||||
{
|
||||
vector<Buffer::TocItem> toclist = (owner_->view()->buffer()->getTocList())[Buffer::TOC_TOC];
|
||||
updateList(&toclist, &toc_);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int const max_number_of_items = 25;
|
||||
|
||||
void Menubar::Pimpl::updateList(vector<Buffer::TocItem> * toclist, vector<ListsHolder> * pgui)
|
||||
{
|
||||
vector<ListsHolder> & gui = *pgui;
|
||||
int szGui = gui.size();
|
||||
int i;
|
||||
for (i=0; i < szGui; ++i)
|
||||
{
|
||||
int oldsz = gui[i].lst.size();
|
||||
vector<Gnome::UI::Info> menu;
|
||||
string label;
|
||||
|
||||
menu.push_back(Gnome::UI::Item(Gnome::UI::Icon(GNOME_STOCK_MENU_REFRESH),
|
||||
_("Refresh"), SigC::slot(this, &Menubar::Pimpl::updateAllLists)));
|
||||
|
||||
if (toclist->size() > max_number_of_items)
|
||||
composeTocUIInfo(menu, *toclist, toclist->begin(), 0);
|
||||
else
|
||||
{
|
||||
vector<Buffer::TocItem>::const_iterator end = toclist->end();
|
||||
for (vector<Buffer::TocItem>::const_iterator it = toclist->begin();
|
||||
it != end; ++it)
|
||||
|
||||
{
|
||||
label = string(4*(*it).depth,' ')+(*it).str;
|
||||
|
||||
menu.push_back(Gnome::UI::Item(label,
|
||||
SigC::bind<Buffer::TocItem>(SigC::slot(this, &Menubar::Pimpl::callbackToc), (*it)),
|
||||
label));
|
||||
}
|
||||
}
|
||||
|
||||
gui[i].lst = menu;
|
||||
mainAppWin->update_menu(gui[i].path, oldsz, gui[i].lst);
|
||||
}
|
||||
}
|
||||
|
||||
vector<Buffer::TocItem>::const_iterator
|
||||
Menubar::Pimpl::composeTocUIInfo(vector<Gnome::UI::Info> & menu,
|
||||
vector<Buffer::TocItem> const & toclist,
|
||||
vector<Buffer::TocItem>::const_iterator begin,
|
||||
int mylevel)
|
||||
{
|
||||
string label = _("<No Name>");
|
||||
|
||||
vector<Buffer::TocItem>::const_iterator end = toclist.end();
|
||||
vector<Buffer::TocItem>::const_iterator it;
|
||||
for (it = begin; it != end && (*it).depth >= mylevel; ++it)
|
||||
{
|
||||
if ( (*it).depth == mylevel &&
|
||||
(it+1 == end || (*(it+1)).depth <= mylevel) )
|
||||
{
|
||||
label = (*it).str;
|
||||
menu.push_back(Gnome::UI::Item(label,
|
||||
SigC::bind<Buffer::TocItem>(SigC::slot(this, &Menubar::Pimpl::callbackToc), (*it)),
|
||||
label));
|
||||
}
|
||||
else
|
||||
{
|
||||
vector<Gnome::UI::Info> submenu;
|
||||
if ( (*it).depth == mylevel )
|
||||
{
|
||||
label = (*it).str;
|
||||
submenu.push_back(Gnome::UI::Item(label,
|
||||
SigC::bind<Buffer::TocItem>(SigC::slot(this, &Menubar::Pimpl::callbackToc), (*it)),
|
||||
label));
|
||||
++it;
|
||||
}
|
||||
it = composeTocUIInfo(submenu, toclist, it, mylevel+1);
|
||||
menu.push_back(Gnome::UI::Menu(label,submenu,label));
|
||||
}
|
||||
}
|
||||
--it;
|
||||
return it;
|
||||
}
|
||||
|
||||
void Menubar::Pimpl::callback(int action)
|
||||
{
|
||||
// Dispatch action OR record action to local variable (see connectWidgetToAction)
|
||||
if (!ignore_action_) {
|
||||
Pimpl::update();
|
||||
owner_->getLyXFunc()->dispatch(action);
|
||||
} else
|
||||
action_ = action;
|
||||
}
|
||||
|
||||
void Menubar::Pimpl::callbackToc(Buffer::TocItem tg)
|
||||
{
|
||||
#if 0
|
||||
if (!owner_->view()->available()) return;
|
||||
|
||||
owner_->view()->beforeChange();
|
||||
owner_->view()->text->SetCursor( owner_->view(), tg.par, 0 );
|
||||
owner_->view()->text->sel_cursor = owner_->view()->text->cursor;
|
||||
owner_->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
||||
#endif
|
||||
|
||||
owner_->getLyXFunc()->dispatch(LFUN_GOTO_PARAGRAPH, tg.str);
|
||||
}
|
||||
|
||||
void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector<Gnome::UI::Info> & Menus, string rootpath)
|
||||
{
|
||||
string path = rootpath;
|
||||
|
||||
if (!menubackend_->hasMenu(menu_name))
|
||||
{
|
||||
cout << "ERROR:composeUIInfo: Unknown menu `" << menu_name
|
||||
<< "'" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
Menu menu = Menu();
|
||||
menubackend_->getMenu(menu_name).expand(menu, owner_->buffer());
|
||||
|
||||
for (Menu::const_iterator i = menu.begin(); i != menu.end(); ++i)
|
||||
{
|
||||
MenuItem item = (*i);
|
||||
switch(item.kind()) {
|
||||
|
||||
case MenuItem::Command: {
|
||||
string label = item.label();
|
||||
|
||||
path = rootpath + label;
|
||||
|
||||
if (label.find(item.shortcut()) != string::npos)
|
||||
label.insert(label.find(item.shortcut()), "_");
|
||||
|
||||
FuncStatus flag = owner_->getLyXFunc()->getStatus(item.action());
|
||||
|
||||
Gnome::UI::Info gitem;
|
||||
SigC::Slot0<void> cback = SigC::bind<int>(SigC::slot(this, &Menubar::Pimpl::callback),item.action());
|
||||
|
||||
{
|
||||
using namespace Gnome::MenuItems;
|
||||
int ac = item.action();
|
||||
kb_action action;
|
||||
string argument;
|
||||
if (lyxaction.isPseudoAction(ac))
|
||||
action = lyxaction.retrieveActionArg(ac, argument);
|
||||
else
|
||||
action = static_cast<kb_action>(ac);
|
||||
|
||||
switch(action) {
|
||||
case LFUN_FILE_OPEN:
|
||||
gitem = Open(cback);
|
||||
break;
|
||||
case LFUN_QUIT:
|
||||
gitem = Exit(cback);
|
||||
break;
|
||||
case LFUN_CLOSEBUFFER:
|
||||
gitem = Close(cback);
|
||||
break;
|
||||
case LFUN_MENUWRITE:
|
||||
gitem = Save(cback);
|
||||
break;
|
||||
case LFUN_WRITEAS:
|
||||
gitem = SaveAs(cback);
|
||||
break;
|
||||
case LFUN_BUFFER_PRINT:
|
||||
gitem = Print(cback);
|
||||
break;
|
||||
case LFUN_CUT:
|
||||
gitem = Cut(cback);
|
||||
break;
|
||||
case LFUN_COPY:
|
||||
gitem = Copy(cback);
|
||||
break;
|
||||
case LFUN_PASTE:
|
||||
gitem = Paste(cback);
|
||||
break;
|
||||
case LFUN_UNDO:
|
||||
gitem = Gnome::MenuItems::Undo(cback); // confused with class Undo
|
||||
break;
|
||||
case LFUN_REDO:
|
||||
gitem = Redo(cback);
|
||||
break;
|
||||
case LFUN_DIALOG_PREFERENCES:
|
||||
gitem = Preferences(cback);
|
||||
break;
|
||||
case LFUN_MENUNEW:
|
||||
gitem = Gnome::UI::Item(Gnome::UI::Icon(GNOME_STOCK_MENU_NEW),
|
||||
label, cback, lyxaction.helpText(item.action()));
|
||||
break;
|
||||
case LFUN_MENUNEWTMPLT:
|
||||
gitem = Gnome::UI::Item(Gnome::UI::Icon(GNOME_STOCK_MENU_NEW),
|
||||
label, cback, lyxaction.helpText(item.action()));
|
||||
break;
|
||||
case LFUN_MENUSEARCH:
|
||||
gitem = Gnome::UI::Item(Gnome::UI::Icon(GNOME_STOCK_MENU_SRCHRPL),
|
||||
label, cback, lyxaction.helpText(item.action()));
|
||||
break;
|
||||
case LFUN_SPELLCHECK:
|
||||
gitem = Gnome::UI::Item(Gnome::UI::Icon(GNOME_STOCK_MENU_SPELLCHECK),
|
||||
label, cback, lyxaction.helpText(item.action()));
|
||||
break;
|
||||
default:
|
||||
gitem = Gnome::UI::Item(label, cback, lyxaction.helpText(item.action()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// first handle optional entries.
|
||||
if (item.optional() && (flag.disabled())) {
|
||||
lyxerr[Debug::GUI]
|
||||
<< "Skipping optional item " << item.label() << endl;
|
||||
break;
|
||||
}
|
||||
if ((flag.onoff(true)) ||
|
||||
(flag.onoff(false)))
|
||||
gitem = Gnome::UI::ToggleItem(label, cback, lyxaction.helpText(item.action()));
|
||||
|
||||
Menus.push_back(gitem);
|
||||
break;
|
||||
}
|
||||
|
||||
case MenuItem::Submenu: {
|
||||
vector<Gnome::UI::Info> submenu;
|
||||
string label = item.label();
|
||||
|
||||
path = rootpath + label;
|
||||
|
||||
if (label.find(item.shortcut()) != string::npos)
|
||||
label.insert(label.find(item.shortcut()), "_");
|
||||
composeUIInfo(item.submenu(), submenu, path + "/");
|
||||
Menus.push_back(Gnome::UI::Menu(label,submenu,label));
|
||||
break;
|
||||
}
|
||||
|
||||
case MenuItem::Separator: {
|
||||
|
||||
path = rootpath + "<Separator>";
|
||||
|
||||
Menus.push_back(Gnome::UI::Separator());
|
||||
break;
|
||||
}
|
||||
|
||||
case MenuItem::Toc: {
|
||||
ListsHolder t;
|
||||
t.path = path;
|
||||
toc_.push_back(t);
|
||||
break;
|
||||
}
|
||||
|
||||
case MenuItem::Documents:
|
||||
case MenuItem::Lastfiles:
|
||||
case MenuItem::ViewFormats:
|
||||
case MenuItem::UpdateFormats:
|
||||
case MenuItem::ExportFormats:
|
||||
lyxerr << "Menubar::Pimpl::create_submenu: "
|
||||
"this should not happen" << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Menubar::Pimpl::connectWidgetToAction(GnomeUIInfo * guinfo)
|
||||
{
|
||||
for (; guinfo->type != GnomeUIInfoType(GNOME_APP_UI_ENDOFINFO); ++guinfo)
|
||||
{
|
||||
if ( ( guinfo->type == GnomeUIInfoType(GNOME_APP_UI_ITEM) ||
|
||||
guinfo->type == GnomeUIInfoType(GNOME_APP_UI_TOGGLEITEM) ) &&
|
||||
guinfo->moreinfo != 0 )
|
||||
{
|
||||
(*((void(*)(void *, void *))(guinfo->moreinfo)))(0, guinfo->user_data);
|
||||
wid_act_.push_back( GtkWidgetToAction( guinfo->widget, action_ ) );
|
||||
}
|
||||
else if ( guinfo->type == GnomeUIInfoType(GNOME_APP_UI_SUBTREE) ||
|
||||
guinfo->type == GnomeUIInfoType(GNOME_APP_UI_RADIOITEMS) )
|
||||
{
|
||||
connectWidgetToAction( (GnomeUIInfo *)(guinfo->moreinfo) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Menubar::Pimpl::update()
|
||||
{
|
||||
vector<GtkWidgetToAction>::const_iterator end=wid_act_.end();
|
||||
for (vector<GtkWidgetToAction>::const_iterator i = wid_act_.begin(); i != end; ++i)
|
||||
{
|
||||
GtkWidgetToAction wa = (*i);
|
||||
FuncStatus flag = owner_->getLyXFunc()->getStatus(wa.action_);
|
||||
|
||||
if ( flag.disabled() || flag.unknown()) gtk_widget_set_sensitive(wa.widget_, false);
|
||||
else gtk_widget_set_sensitive(wa.widget_, true);
|
||||
|
||||
if ( flag.onoff(true))
|
||||
{
|
||||
ignore_action_=true;
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(wa.widget_), true);
|
||||
ignore_action_=false;
|
||||
}
|
||||
|
||||
if ( flag.onoff(false))
|
||||
{
|
||||
ignore_action_=true;
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(wa.widget_), false);
|
||||
ignore_action_=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Menubar::Pimpl::openByName(string const &)
|
||||
{
|
||||
// Pimpl::update();
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 2000 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#ifndef MENUBAR_PIMPL_H
|
||||
#define MENUBAR_PIMPL_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include "gettext.h"
|
||||
#include "LString.h"
|
||||
#include <gnome--/app.h>
|
||||
#include <gnome--/app-helper.h>
|
||||
#include "frontends/Menubar.h"
|
||||
#include "commandtags.h"
|
||||
#include "buffer.h"
|
||||
|
||||
class LyXView;
|
||||
class MenuBackend;
|
||||
class MenuItem;
|
||||
class StrPool;
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
/*
|
||||
Structure containing Gtk widget and corresponding LyX action
|
||||
*/
|
||||
struct GtkWidgetToAction
|
||||
{
|
||||
public:
|
||||
GtkWidgetToAction(GtkWidget * w, int a) { widget_=w; action_=a; }
|
||||
|
||||
public:
|
||||
GtkWidget * widget_;
|
||||
int action_;
|
||||
};
|
||||
|
||||
/** The LyX GUI independent menubar class
|
||||
The GUI interface is implemented in the corresponding Menubar_pimpl class.
|
||||
*/
|
||||
class Menubar::Pimpl: public SigC::Object {
|
||||
public:
|
||||
///
|
||||
Pimpl(LyXView *, MenuBackend const &);
|
||||
///
|
||||
~Pimpl();
|
||||
///
|
||||
void set(string const &);
|
||||
/// Opens a top-level submenu given its name
|
||||
void openByName(string const &);
|
||||
/// update the state of menuitems
|
||||
void update();
|
||||
/// update TOC, LOF, ... on user' request
|
||||
void updateAllLists();
|
||||
|
||||
protected:
|
||||
/// callback function
|
||||
void callback(int action);
|
||||
/// callback function used by lists
|
||||
void callbackToc(Buffer::TocItem tg);
|
||||
/// compose Gnome::UI::Array object describing the menu
|
||||
void composeUIInfo(string const & menu_name, vector<Gnome::UI::Info> & Menus, string path);
|
||||
/// compose Gnome::UI::Array object describing the TOClist
|
||||
vector<Buffer::TocItem>::const_iterator
|
||||
composeTocUIInfo(vector<Gnome::UI::Info> & menu,
|
||||
vector<Buffer::TocItem> const & toclist,
|
||||
vector<Buffer::TocItem>::const_iterator begin,
|
||||
int mylevel);
|
||||
/// populate wid_act_ vector with all widgets and corresponding actions
|
||||
void connectWidgetToAction(GnomeUIInfo * guinfo);
|
||||
|
||||
/// lists (toc, lof, lot, loa)
|
||||
struct ListsHolder {
|
||||
string path;
|
||||
Gnome::UI::Array<Gnome::UI::Info> lst;
|
||||
|
||||
ListsHolder () { }
|
||||
ListsHolder (const ListsHolder & a) { path = a.path; lst = a.lst; }
|
||||
};
|
||||
/// populate lists
|
||||
void updateList(vector<Buffer::TocItem> *, vector<ListsHolder> *);
|
||||
|
||||
private:
|
||||
///
|
||||
LyXView * owner_;
|
||||
///
|
||||
MenuBackend const * menubackend_;
|
||||
///
|
||||
string current_menu_name_;
|
||||
Gnome::UI::Array<Gnome::UI::Info> Menu_;
|
||||
|
||||
///
|
||||
bool ignore_action_;
|
||||
int action_;
|
||||
vector<GtkWidgetToAction> wid_act_;
|
||||
|
||||
/// toc
|
||||
SigC::Connection utoc_;
|
||||
vector<ListsHolder> toc_;
|
||||
};
|
||||
#endif
|
@ -1,153 +0,0 @@
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 2000 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <gnome--/main.h>
|
||||
#include <gtk--/accelgroup.h>
|
||||
#include <gnome--/pixmap.h>
|
||||
#include <gtk--/separator.h>
|
||||
#include <gtk--/frame.h>
|
||||
#include <gtk--/label.h>
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "mainapp.h"
|
||||
|
||||
using SigC::bind;
|
||||
using SigC::slot;
|
||||
|
||||
GLyxAppWin::GLyxAppWin() :
|
||||
Gnome::App(PACKAGE,"LyX Gnomified"),
|
||||
status_(false, true, GNOME_PREFERENCES_NEVER),
|
||||
action_mode(false)
|
||||
{
|
||||
init();
|
||||
show_all();
|
||||
}
|
||||
|
||||
GLyxAppWin::~GLyxAppWin()
|
||||
{
|
||||
}
|
||||
|
||||
void GLyxAppWin::init()
|
||||
{
|
||||
// set defaults
|
||||
set_policy(false, true, false);
|
||||
set_default_size(250, 350);
|
||||
set_wmclass(PACKAGE, "GnomeLyX");
|
||||
|
||||
set_statusbar(status_);
|
||||
|
||||
accel_ = 0;
|
||||
|
||||
// initial (dummy) menu
|
||||
vector<Gnome::UI::Info> menus, fm;
|
||||
fm.push_back(Gnome::MenuItems::Open());
|
||||
menus.push_back(Gnome::Menus::File(fm));
|
||||
|
||||
GLyxAppWin::Array menu = menus;
|
||||
gnome_app_create_menus(this->gtkobj(),
|
||||
menu.gtkobj());
|
||||
|
||||
menusize_ = menu.size();
|
||||
|
||||
// packing widgets
|
||||
|
||||
// temporary main widget
|
||||
Gtk::HBox * h = manage( new Gtk::HBox() );
|
||||
Gnome::Pixmap * p;
|
||||
p = Gtk::wrap( GNOME_PIXMAP( gnome_stock_pixmap_widget(0, GNOME_STOCK_PIXMAP_ABOUT) ) );
|
||||
|
||||
h->children().push_back( Gtk::Box_Helpers::Element( *p ) );
|
||||
h->children().push_back( *(manage(new Gtk::Label("Waiting for LyXView port"))) );
|
||||
|
||||
view_ = h;
|
||||
// temporary main widget: done
|
||||
|
||||
// packing main widget and separator
|
||||
Gtk::Separator * sep = manage( new Gtk::HSeparator() );
|
||||
|
||||
box_.children().push_back( Gtk::Box_Helpers::Element(*view_) );
|
||||
box_.children().push_back( Gtk::Box_Helpers::Element(*sep, false) );
|
||||
|
||||
box_.show_all();
|
||||
|
||||
set_contents(box_);
|
||||
|
||||
key_press_event.connect(slot(this, &GLyxAppWin::key_pressed));
|
||||
}
|
||||
|
||||
|
||||
void GLyxAppWin::set_menu(Array &menu)
|
||||
{
|
||||
// clean up and install new menus
|
||||
gnome_app_remove_menus(this->gtkobj(),"/",menusize_);
|
||||
gnome_app_insert_menus(this->gtkobj(), "", menu.gtkobj());
|
||||
gnome_app_install_menu_hints(this->gtkobj(), menu.gtkobj());
|
||||
menusize_ = menu.size();
|
||||
}
|
||||
|
||||
void GLyxAppWin::update_menu(string path, int noelms, Array &menu)
|
||||
{
|
||||
// remove "noelms" items and install new items from "menu"
|
||||
gnome_app_remove_menus(this->gtkobj(),path.c_str(),noelms);
|
||||
gnome_app_insert_menus(this->gtkobj(),path.c_str(),menu.gtkobj());
|
||||
gnome_app_install_menu_hints(this->gtkobj(),menu.gtkobj());
|
||||
}
|
||||
|
||||
// clean up first, then add new action widget and finally, disable main view
|
||||
void GLyxAppWin::add_action(Gtk::Container &action, string title, bool expand, Gtk::AccelGroup * acgr)
|
||||
{
|
||||
remove_action();
|
||||
|
||||
Gtk::Frame * frame = manage( new Gtk::Frame(title) );
|
||||
frame->set_border_width(2);
|
||||
action.set_border_width(2);
|
||||
frame->add(action);
|
||||
|
||||
box_.children().push_back( Gtk::Box_Helpers::Element( *frame, expand ) );
|
||||
box_.show_all();
|
||||
|
||||
accel_ = acgr;
|
||||
if (accel_ != 0) add_accel_group(*accel_);
|
||||
|
||||
view_->set_sensitive(false);
|
||||
action_mode = true;
|
||||
}
|
||||
|
||||
void GLyxAppWin::remove_action()
|
||||
{
|
||||
if (accel_ != 0)
|
||||
{
|
||||
remove_accel_group(*accel_);
|
||||
accel_ = 0;
|
||||
}
|
||||
|
||||
while ( box_.children().size() > 2 )
|
||||
{
|
||||
box_.children().pop_back();
|
||||
}
|
||||
|
||||
view_->set_sensitive(true);
|
||||
action_mode = false;
|
||||
}
|
||||
|
||||
gint GLyxAppWin::key_pressed(GdkEventKey * e)
|
||||
{
|
||||
if (action_mode &&
|
||||
e->keyval == GDK_Escape)
|
||||
{
|
||||
remove_action();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1,67 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 2000 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#ifndef GNOMELYX_MAINWIN
|
||||
#define GNOMELYX_MAINWIN
|
||||
|
||||
#include <gnome--/app.h>
|
||||
#include <gnome--/appbar.h>
|
||||
#include <gnome--/app-helper.h>
|
||||
#include <gtk--/frame.h>
|
||||
#include <gtk--/accelgroup.h>
|
||||
|
||||
#include "MenuBackend.h"
|
||||
|
||||
/*
|
||||
This is (most probably) temporary class and it will be either merged with
|
||||
LyXView or replaced by new implementation of GUI-dependend MainWindow class
|
||||
*/
|
||||
|
||||
class GLyxAppWin: public Gnome::App
|
||||
{
|
||||
public:
|
||||
///
|
||||
typedef Gnome::UI::Array<Gnome::UI::Info> Array;
|
||||
|
||||
GLyxAppWin();
|
||||
~GLyxAppWin();
|
||||
|
||||
/// set menu of the window
|
||||
void set_menu(Array &);
|
||||
/// update menu
|
||||
void update_menu(string path,
|
||||
int noelms,
|
||||
Array &);
|
||||
/// add action area
|
||||
void add_action(Gtk::Container &, string title, bool expand=false, Gtk::AccelGroup * acgr=0);
|
||||
/// remove action area
|
||||
void remove_action();
|
||||
/// clears action area if Escape is pressed
|
||||
gint key_pressed(GdkEventKey * e);
|
||||
|
||||
protected:
|
||||
/// init window widgets
|
||||
void init();
|
||||
|
||||
protected:
|
||||
// widgets
|
||||
Gnome::AppBar status_;
|
||||
Gtk::VBox box_;
|
||||
Gtk::Widget *view_;
|
||||
|
||||
Gtk::AccelGroup * accel_;
|
||||
|
||||
bool action_mode;
|
||||
|
||||
// menu size
|
||||
int menusize_;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user