1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2000 The LyX Team.
8 * ====================================================== */
12 #include <gnome--/main.h>
13 #include <gtk--/accelgroup.h>
14 #include <gnome--/pixmap.h>
15 #include <gtk--/separator.h>
16 #include <gtk--/frame.h>
17 #include <gtk--/label.h>
27 GLyxAppWin::GLyxAppWin() :
28 Gnome::App(PACKAGE,"LyX Gnomified"),
29 status_(false, true, GNOME_PREFERENCES_NEVER),
36 GLyxAppWin::~GLyxAppWin()
40 void GLyxAppWin::init()
43 set_policy(false, true, false);
44 set_default_size(250, 350);
45 set_wmclass(PACKAGE, "GnomeLyX");
47 set_statusbar(status_);
51 // initial (dummy) menu
52 vector<Gnome::UI::Info> menus, fm;
53 fm.push_back(Gnome::MenuItems::Open());
54 menus.push_back(Gnome::Menus::File(fm));
56 Gnome::UI::Array menu = menus;
57 gnome_app_create_menus(this->gtkobj(),
60 menusize_ = menu.size();
64 // temporary main widget
65 Gtk::HBox * h = manage( new Gtk::HBox() );
67 p = Gtk::wrap( GNOME_PIXMAP( gnome_stock_pixmap_widget(0, GNOME_STOCK_PIXMAP_ABOUT) ) );
69 h->children().push_back( Gtk::Box_Helpers::Element( *p ) );
70 h->children().push_back( *(manage(new Gtk::Label("Waiting for LyXView port"))) );
73 // temporary main widget: done
75 // packing main widget and separator
76 Gtk::Separator * sep = manage( new Gtk::HSeparator() );
78 box_.children().push_back( Gtk::Box_Helpers::Element(*view_) );
79 box_.children().push_back( Gtk::Box_Helpers::Element(*sep, false) );
85 key_press_event.connect(slot(this, &GLyxAppWin::key_pressed));
89 void GLyxAppWin::set_menu(Gnome::UI::Array &menu)
91 // clean up and install new menus
92 gnome_app_remove_menus(this->gtkobj(),"/",menusize_);
93 gnome_app_insert_menus(this->gtkobj(), "", menu.gtkobj());
94 gnome_app_install_menu_hints(this->gtkobj(), menu.gtkobj());
95 menusize_ = menu.size();
98 void GLyxAppWin::update_menu(string path, int noelms, Gnome::UI::Array &menu)
100 // remove "noelms" items and install new items from "menu"
101 gnome_app_remove_menus(this->gtkobj(),path.c_str(),noelms);
102 gnome_app_insert_menus(this->gtkobj(),path.c_str(),menu.gtkobj());
103 gnome_app_install_menu_hints(this->gtkobj(),menu.gtkobj());
106 // clean up first, then add new action widget and finally, disable main view
107 void GLyxAppWin::add_action(Gtk::Container &action, string title, bool expand, Gtk::AccelGroup * acgr)
111 Gtk::Frame * frame = manage( new Gtk::Frame(title) );
112 frame->set_border_width(2);
113 action.set_border_width(2);
116 box_.children().push_back( Gtk::Box_Helpers::Element( *frame, expand ) );
120 if (accel_ != 0) add_accel_group(*accel_);
122 view_->set_sensitive(false);
126 void GLyxAppWin::remove_action()
130 remove_accel_group(*accel_);
134 while ( box_.children().size() > 2 )
136 box_.children().pop_back();
139 view_->set_sensitive(true);
143 gint GLyxAppWin::key_pressed(GdkEventKey * e)
146 e->keyval == GDK_Escape)