2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ====================================================== */
13 #include <gnome--/main.h>
14 #include <gtk--/accelgroup.h>
15 #include <gnome--/pixmap.h>
16 #include <gtk--/separator.h>
17 #include <gtk--/frame.h>
18 #include <gtk--/label.h>
28 GLyxAppWin::GLyxAppWin() :
29 Gnome::App(PACKAGE,"LyX Gnomified"),
30 status_(false, true, GNOME_PREFERENCES_NEVER),
37 GLyxAppWin::~GLyxAppWin()
41 void GLyxAppWin::init()
44 set_policy(false, true, false);
45 set_default_size(250, 350);
46 set_wmclass(PACKAGE, "GnomeLyX");
48 set_statusbar(status_);
50 // initial (dummy) menu
51 vector<Gnome::UI::Info> menus, fm;
52 fm.push_back(Gnome::MenuItems::Open());
53 menus.push_back(Gnome::Menus::File(fm));
55 Gnome::UI::Array menu = menus;
56 gnome_app_create_menus(this->gtkobj(),
59 menusize_ = menu.size();
63 // temporary main widget
64 Gtk::HBox * h = manage( new Gtk::HBox() );
66 p = Gtk::wrap( GNOME_PIXMAP( gnome_stock_pixmap_widget(NULL, GNOME_STOCK_PIXMAP_ABOUT) ) );
68 h->children().push_back( Gtk::Box_Helpers::Element( *p ) );
69 h->children().push_back( *(manage(new Gtk::Label("Waiting for LyXView port"))) );
72 // temporary main widget: done
74 // packing main widget and separator
75 Gtk::Separator * sep = manage( new Gtk::HSeparator() );
77 box_.children().push_back( Gtk::Box_Helpers::Element(*view_) );
78 box_.children().push_back( Gtk::Box_Helpers::Element(*sep, false) );
84 key_press_event.connect(slot(this, &GLyxAppWin::key_pressed));
88 void GLyxAppWin::set_menu(Gnome::UI::Array &menu)
90 // clean up and install new menus
91 gnome_app_remove_menus(this->gtkobj(),"/",menusize_);
92 gnome_app_insert_menus(this->gtkobj(), "", menu.gtkobj());
93 gnome_app_install_menu_hints(this->gtkobj(), menu.gtkobj());
94 menusize_ = menu.size();
97 void GLyxAppWin::update_menu(string path, int noelms, Gnome::UI::Array &menu)
99 // remove "noelms" items and install new items from "menu"
100 gnome_app_remove_menus(this->gtkobj(),path.c_str(),noelms);
101 gnome_app_insert_menus(this->gtkobj(),path.c_str(),menu.gtkobj());
102 gnome_app_install_menu_hints(this->gtkobj(),menu.gtkobj());
105 // clean up first, then add new action widget and finally, disable main view
106 void GLyxAppWin::add_action(Gtk::Container &action, string title, bool expand)
110 Gtk::Frame * frame = manage( new Gtk::Frame(title) );
111 frame->set_border_width(2);
112 action.set_border_width(2);
115 box_.children().push_back( Gtk::Box_Helpers::Element( *frame, expand ) );
118 view_->set_sensitive(false);
122 void GLyxAppWin::remove_action()
124 while ( box_.children().size() > 2 )
126 box_.children().pop_back();
129 view_->set_sensitive(true);
133 gint GLyxAppWin::key_pressed(GdkEventKey * e)
136 e->keyval == GDK_Escape)