Exemplo n.º 1
0
void TableofcontentsNoteAddin::populate_toc_menu (Gtk::Menu *toc_menu, bool has_action_entries)
//populate a menu with Note's table of contents
{
    // Clear out the old list
    std::vector<Gtk::Widget*> menu_items = toc_menu->get_children();
    for(std::vector<Gtk::Widget*>::reverse_iterator iter = menu_items.rbegin();
            iter != menu_items.rend(); ++iter) {
        toc_menu->remove(**iter);
    }

    // Build a new list
    std::list<TableofcontentsMenuItem*> items;
    get_tableofcontents_menu_items(items);

    for(std::list<TableofcontentsMenuItem*>::iterator iter = items.begin();
            iter != items.end(); ++iter) {
        TableofcontentsMenuItem *item(*iter);
        item->show_all();
        toc_menu->append(*item);
    }

    // Action menu items, or nothing
    if (has_action_entries == false) {
        if (toc_menu->get_children().size() == 0) { // no toc items, and no action entries = empty menu
            Gtk::MenuItem *item = manage(new Gtk::MenuItem(_("(empty table of contents)")));
            item->set_sensitive(false);
            item->show();
            toc_menu->append(*item);
        }
    }
    else {
        Gtk::MenuItem *item;

        if (toc_menu->get_children().size() != 0) { //there are toc items, we add a separator
            item = manage(new Gtk::SeparatorMenuItem ());
            item->show ();
            toc_menu->append(*item);
        }

        item = manage(new Gtk::MenuItem (_("Heading 1")));
        item->add_accelerator("activate", get_note()->get_window()->get_accel_group(), GDK_KEY_1, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE);
        item->signal_activate().connect(sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_level_1_activated));
        item->show ();
        toc_menu->append(*item);

        item = manage(new Gtk::MenuItem (_("Heading 2")));
        item->add_accelerator("activate", get_note()->get_window()->get_accel_group(), GDK_KEY_2, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE);
        item->signal_activate().connect(sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_level_2_activated));
        item->show ();
        toc_menu->append(*item);

        item = manage(new Gtk::MenuItem (_("Table of Contents Help")));
        item->signal_activate().connect(sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_toc_help_activated));
        item->show ();
        toc_menu->append(*item);
    }

}
Exemplo n.º 2
0
//------------------------------------------------------------------------------
bool mforms::gtk::MenuItemImpl::create_menu_item(mforms::MenuItem *item, const std::string &label,
                                                 const mforms::MenuItemType type) {
  Gtk::MenuItem *mi = cast<Gtk::MenuItem *>(item->get_data_ptr());

  if (mi) {
    item->set_data(0);
    delete mi;
  }

  if (type == mforms::SeparatorMenuItem)
    item->set_data(Gtk::manage(new Gtk::SeparatorMenuItem()));
  else {
    if (type == mforms::CheckedMenuItem) {
      Gtk::CheckMenuItem *ci = Gtk::manage(new Gtk::CheckMenuItem(label));
      item->set_data(ci);
    } else
      item->set_data(Gtk::manage(new Gtk::MenuItem(label)));
  }

  mi = cast<Gtk::MenuItem *>(item->get_data_ptr());
  if (mi) {
    mi->show();
    if (type != mforms::SeparatorMenuItem) {
      mi->set_use_underline(true);
      mi->signal_activate().connect(sigc::bind(sigc::ptr_fun(process_click), mi, item));
    }
  }

  return mi;
}
Exemplo n.º 3
0
    void GlobalKeybinder::add_accelerator(const sigc::slot<void> & handler, guint key, 
                                          Gdk::ModifierType modifiers, Gtk::AccelFlags flags)
    {
      Gtk::MenuItem *foo = manage(new Gtk::MenuItem ());
      foo->signal_activate().connect(handler);
      foo->add_accelerator ("activate",
                          m_accel_group,
                          key,
                          modifiers,
                          flags);
      foo->show ();

      m_fake_menu.append (*foo);
    }
Exemplo n.º 4
0
//------------------------------------------------------------------------------
int mforms::gtk::MenuImpl::add_item(Menu *self, const std::string &caption, const std::string &action)
{
    int index = -1;
    MenuImpl* menu = self->get_data<MenuImpl>();
    if (menu)
    {
        Gtk::MenuItem *item = Gtk::manage(new Gtk::MenuItem(caption, true));
        menu->_menu.append(*item);
        item->show();
        index = menu->_menu.items().size() - 1;
        item->signal_activate().connect(sigc::bind(sigc::mem_fun(self, &mforms::Menu::handle_action), action));
    }
    return index;
}
Exemplo n.º 5
0
//------------------------------------------------------------------------------
int mforms::gtk::MenuImpl::add_submenu(Menu *self, const std::string &caption, Menu *submenu)
{
    int index = -1;
    MenuImpl* menu = self->get_data<MenuImpl>();
    MenuImpl* sub_menu = submenu->get_data<MenuImpl>();
    if (menu)
    {
        Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem(caption, true));
        item->set_submenu(sub_menu->_menu);
        menu->_menu.append(*item);
        item->show();
        index = menu->_menu.items().size() - 1;
    }
    return index;
}
Exemplo n.º 6
0
bool
DockBook::tab_button_pressed(GdkEventButton* event, Dockable* dockable)
{
	CanvasView *canvas_view = dynamic_cast<CanvasView*>(dockable);
	if (canvas_view && canvas_view != App::get_selected_canvas_view())
		App::set_selected_canvas_view(canvas_view);

	if(event->button!=3)
		return false;

	Gtk::Menu *tabmenu=manage(new class Gtk::Menu());
	tabmenu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), tabmenu));

	Gtk::MenuItem *item = manage(new Gtk::ImageMenuItem(Gtk::StockID("gtk-close")));
	item->signal_activate().connect(
		sigc::bind(sigc::ptr_fun(&DockManager::remove_widget_by_pointer_recursive), dockable) );

	tabmenu->append(*item);
	item->show();
	tabmenu->popup(event->button,gtk_get_current_event_time());

	return true;
}