2000-08-09 13:51:59 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2000 The LyX Team.
|
|
|
|
*
|
|
|
|
* ====================================================== */
|
|
|
|
|
|
|
|
#include <config.h>
|
2000-09-19 13:50:47 +00:00
|
|
|
|
2000-08-09 13:51:59 +00:00
|
|
|
#include <gnome--/main.h>
|
|
|
|
#include <gtk--/accelgroup.h>
|
2000-09-19 13:50:47 +00:00
|
|
|
#include <gnome--/pixmap.h>
|
|
|
|
#include <gtk--/separator.h>
|
|
|
|
#include <gtk--/frame.h>
|
|
|
|
#include <gtk--/label.h>
|
|
|
|
|
2000-08-09 13:51:59 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include "mainapp.h"
|
|
|
|
|
|
|
|
using SigC::bind;
|
|
|
|
using SigC::slot;
|
|
|
|
|
|
|
|
GLyxAppWin::GLyxAppWin() :
|
2000-09-05 15:06:55 +00:00
|
|
|
Gnome::App(PACKAGE,"LyX Gnomified"),
|
2000-09-19 13:50:47 +00:00
|
|
|
status_(false, true, GNOME_PREFERENCES_NEVER),
|
|
|
|
action_mode(false)
|
2000-08-09 13:51:59 +00:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
show_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
GLyxAppWin::~GLyxAppWin()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLyxAppWin::init()
|
|
|
|
{
|
|
|
|
// set defaults
|
|
|
|
set_policy(false, true, false);
|
|
|
|
set_default_size(250, 350);
|
2000-09-05 15:06:55 +00:00
|
|
|
set_wmclass(PACKAGE, "GnomeLyX");
|
2000-08-09 13:51:59 +00:00
|
|
|
|
|
|
|
set_statusbar(status_);
|
|
|
|
|
2000-10-30 11:33:05 +00:00
|
|
|
accel_ = 0;
|
2000-09-25 11:10:15 +00:00
|
|
|
|
2000-08-09 13:51:59 +00:00
|
|
|
// initial (dummy) menu
|
|
|
|
vector<Gnome::UI::Info> menus, fm;
|
|
|
|
fm.push_back(Gnome::MenuItems::Open());
|
|
|
|
menus.push_back(Gnome::Menus::File(fm));
|
|
|
|
|
|
|
|
Gnome::UI::Array menu = menus;
|
|
|
|
gnome_app_create_menus(this->gtkobj(),
|
|
|
|
menu.gtkobj());
|
|
|
|
|
|
|
|
menusize_ = menu.size();
|
2000-09-19 13:50:47 +00:00
|
|
|
|
|
|
|
// packing widgets
|
|
|
|
|
|
|
|
// temporary main widget
|
|
|
|
Gtk::HBox * h = manage( new Gtk::HBox() );
|
|
|
|
Gnome::Pixmap * p;
|
2000-10-30 11:33:05 +00:00
|
|
|
p = Gtk::wrap( GNOME_PIXMAP( gnome_stock_pixmap_widget(0, GNOME_STOCK_PIXMAP_ABOUT) ) );
|
2000-09-19 13:50:47 +00:00
|
|
|
|
|
|
|
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));
|
2000-08-09 13:51:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GLyxAppWin::set_menu(Gnome::UI::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();
|
|
|
|
}
|
|
|
|
|
2000-09-19 13:50:47 +00:00
|
|
|
void GLyxAppWin::update_menu(string path, int noelms, Gnome::UI::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
|
2000-09-25 11:10:15 +00:00
|
|
|
void GLyxAppWin::add_action(Gtk::Container &action, string title, bool expand, Gtk::AccelGroup * acgr)
|
2000-09-19 13:50:47 +00:00
|
|
|
{
|
|
|
|
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();
|
|
|
|
|
2000-09-25 11:10:15 +00:00
|
|
|
accel_ = acgr;
|
2000-10-30 11:33:05 +00:00
|
|
|
if (accel_ != 0) add_accel_group(*accel_);
|
2000-09-25 11:10:15 +00:00
|
|
|
|
2000-09-19 13:50:47 +00:00
|
|
|
view_->set_sensitive(false);
|
|
|
|
action_mode = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLyxAppWin::remove_action()
|
|
|
|
{
|
2000-10-30 11:33:05 +00:00
|
|
|
if (accel_ != 0)
|
2000-09-25 11:10:15 +00:00
|
|
|
{
|
|
|
|
remove_accel_group(*accel_);
|
2000-10-30 11:33:05 +00:00
|
|
|
accel_ = 0;
|
2000-09-25 11:10:15 +00:00
|
|
|
}
|
|
|
|
|
2000-09-19 13:50:47 +00:00
|
|
|
while ( box_.children().size() > 2 )
|
|
|
|
{
|
|
|
|
box_.children().pop_back();
|
|
|
|
}
|
2000-09-25 11:10:15 +00:00
|
|
|
|
2000-09-19 13:50:47 +00:00
|
|
|
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;
|
|
|
|
}
|
2000-08-09 13:51:59 +00:00
|
|
|
|