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_);
52 // initial (dummy) menu
53 vector<Gnome::UI::Info> menus, fm;
54 fm.push_back(Gnome::MenuItems::Open());
55 menus.push_back(Gnome::Menus::File(fm));
57 Gnome::UI::Array menu = menus;
58 gnome_app_create_menus(this->gtkobj(),
61 menusize_ = menu.size();
65 // temporary main widget
66 Gtk::HBox * h = manage( new Gtk::HBox() );
68 p = Gtk::wrap( GNOME_PIXMAP( gnome_stock_pixmap_widget(0, GNOME_STOCK_PIXMAP_ABOUT) ) );
70 h->children().push_back( Gtk::Box_Helpers::Element( *p ) );
71 h->children().push_back( *(manage(new Gtk::Label("Waiting for LyXView port"))) );
74 // temporary main widget: done
76 // packing main widget and separator
77 Gtk::Separator * sep = manage( new Gtk::HSeparator() );
79 box_.children().push_back( Gtk::Box_Helpers::Element(*view_) );
80 box_.children().push_back( Gtk::Box_Helpers::Element(*sep, false) );
86 key_press_event.connect(slot(this, &GLyxAppWin::key_pressed));
90 void GLyxAppWin::set_menu(Gnome::UI::Array &menu)
92 // clean up and install new menus
93 gnome_app_remove_menus(this->gtkobj(),"/",menusize_);
94 gnome_app_insert_menus(this->gtkobj(), "", menu.gtkobj());
95 gnome_app_install_menu_hints(this->gtkobj(), menu.gtkobj());
96 menusize_ = menu.size();
99 void GLyxAppWin::update_menu(string path, int noelms, Gnome::UI::Array &menu)
101 // remove "noelms" items and install new items from "menu"
102 gnome_app_remove_menus(this->gtkobj(),path.c_str(),noelms);
103 gnome_app_insert_menus(this->gtkobj(),path.c_str(),menu.gtkobj());
104 gnome_app_install_menu_hints(this->gtkobj(),menu.gtkobj());
107 // clean up first, then add new action widget and finally, disable main view
108 void GLyxAppWin::add_action(Gtk::Container &action, string title, bool expand, Gtk::AccelGroup * acgr)
112 Gtk::Frame * frame = manage( new Gtk::Frame(title) );
113 frame->set_border_width(2);
114 action.set_border_width(2);
117 box_.children().push_back( Gtk::Box_Helpers::Element( *frame, expand ) );
121 if (accel_ != 0) add_accel_group(*accel_);
123 view_->set_sensitive(false);
127 void GLyxAppWin::remove_action()
131 remove_accel_group(*accel_);
135 while ( box_.children().size() > 2 )
137 box_.children().pop_back();
140 view_->set_sensitive(true);
144 gint GLyxAppWin::key_pressed(GdkEventKey * e)
147 e->keyval == GDK_Escape)