Ejemplo n.º 1
0
  void NotebookNoteAddin::update_menu()
  {
    //
    // Clear out the old list
    //
    for(std::list<Gtk::MenuItem *>::const_iterator iter = m_menu_items.begin();
        iter != m_menu_items.end(); ++iter) {
      m_menu->remove (**iter);
    }
    m_menu_items.clear();

    //
    // Build a new menu
    //
      
    // Add the "New Notebook..."
    Gtk::ImageMenuItem *newNotebookMenuItem =
      manage(new Gtk::ImageMenuItem (_("_New notebook..."), true));
    newNotebookMenuItem->set_image(*manage(new Gtk::Image(
      IconManager::obj().get_icon(IconManager::NOTEBOOK_NEW, 16))));
    newNotebookMenuItem->signal_activate()
      .connect(sigc::mem_fun(*this,&NotebookNoteAddin::on_new_notebook_menu_item));
    newNotebookMenuItem->show ();
    m_menu->append (*newNotebookMenuItem);
    m_menu_items.push_back(newNotebookMenuItem);
      
    // Add the "(no notebook)" item at the top of the list
    NotebookMenuItem *noNotebookMenuItem = manage(new NotebookMenuItem (m_radio_group,
                                                    get_note(), Notebook::Ptr()));
    noNotebookMenuItem->show_all ();
    m_menu->append (*noNotebookMenuItem);
    m_menu_items.push_back(noNotebookMenuItem);

    NotebookMenuItem *active_menu_item = noNotebookMenuItem;
    Notebook::Ptr current_notebook = NotebookManager::obj().get_notebook_from_note(get_note());
      
    // Add in all the real notebooks
    std::list<NotebookMenuItem*> notebookMenuItems;
    get_notebook_menu_items (notebookMenuItems);
    if (!notebookMenuItems.empty()) {
      Gtk::SeparatorMenuItem *separator = manage(new Gtk::SeparatorMenuItem ());
      separator->show_all ();
      m_menu->append (*separator);
      m_menu_items.push_back(separator);
        
      for(std::list<NotebookMenuItem*>::const_iterator iter = notebookMenuItems.begin();
          iter != notebookMenuItems.end(); ++iter) {
        NotebookMenuItem* item = *iter;
        item->show_all ();
        m_menu->append (*item);
        m_menu_items.push_back(item);
        if(current_notebook == item->get_notebook())
          active_menu_item = item;
      }
    }

    active_menu_item->set_active(true);
  }
Ejemplo n.º 2
0
//------------------------------------------------------------------------------
int mforms::gtk::MenuImpl::add_separator(Menu *self)
{
    int index = -1;
    MenuImpl* menu = self->get_data<MenuImpl>();
    if (menu)
    {
        Gtk::SeparatorMenuItem *sep = Gtk::manage(new Gtk::SeparatorMenuItem());
        menu->_menu.append(*sep);
        sep->show();
        index = menu->_menu.items().size() - 1;
    }
    return index;
}
Ejemplo n.º 3
0
void TableofcontentsNoteAddin::on_populate_popup (Gtk::Menu* popup_menu)
//prepened a toc submenu in the contextual menu
{
    Gtk::Menu *toc_menu = manage(new Gtk::Menu());
    populate_toc_menu (toc_menu);

    Gtk::SeparatorMenuItem *separator = manage(new Gtk::SeparatorMenuItem ());
    separator->show ();
    popup_menu->prepend (*separator);

    Gtk::ImageMenuItem *menu_item = new_toc_menu_item ();
    menu_item->set_submenu (*toc_menu);
    menu_item->show ();

    popup_menu->prepend (*menu_item);
}
Ejemplo n.º 4
0
    void NotebookApplicationAddin::add_menu_items(Gtk::Menu * menu,   
                                                  std::list<Gtk::MenuItem*> & menu_items)
    {
      remove_menu_items (menu, menu_items);      

      NotebookNewNoteMenuItem *item;

      Glib::RefPtr<Gtk::TreeModel> model = NotebookManager::obj().get_notebooks();
      Gtk::TreeIter iter;
      
      // Add in the "New Notebook..." menu item
      Gtk::ImageMenuItem *newNotebookMenuItem =
        manage(new Gtk::ImageMenuItem (_("New Note_book..."), true));
      newNotebookMenuItem->set_image(*manage(new Gtk::Image(
          IconManager::obj().get_icon(IconManager::NOTEBOOK_NEW, 16))));
      newNotebookMenuItem->signal_activate()
        .connect(sigc::mem_fun(*this, &NotebookApplicationAddin::on_new_notebook_menu_item));
      newNotebookMenuItem->show_all ();
      menu->append (*newNotebookMenuItem);
      menu_items.push_back(newNotebookMenuItem);

      
      if (model->children().size() > 0) {
        Gtk::SeparatorMenuItem *separator = manage(new Gtk::SeparatorMenuItem ());
        separator->show_all ();
        menu->append (*separator);
        menu_items.push_back(separator);
        
        iter = model->children().begin();
        while (iter) {
          Notebook::Ptr notebook;
          iter->get_value(0, notebook);
          item = manage(new NotebookNewNoteMenuItem (notebook));
          item->show_all ();
          menu->append (*item);
          menu_items.push_back(item);
          ++iter;
        }
      }
    }