Exemplo n.º 1
0
void mforms::gtk::MenuItemImpl::insert_item(mforms::MenuBase *menub, int index, mforms::MenuItem *item) {
  Gtk::MenuShell *menu_shell = cast<Gtk::MenuShell *>(menub->get_data_ptr());
  Gtk::MenuItem *item_to_insert = cast<Gtk::MenuItem *>(item->get_data_ptr());

  if (!menu_shell) // menub is not a menubar
  {
    Gtk::MenuItem *mi = cast<Gtk::MenuItem *>(menub->get_data_ptr());
    if (mi) {
      Gtk::Menu *menu = 0;
      if (mi->has_submenu()) // item already has submenu, add to it
        menu = mi->get_submenu();
      else { // no submenu yet in item, create one
        menu = Gtk::manage(new Gtk::Menu());
        mi->signal_activate().connect(sigc::bind(sigc::ptr_fun(menu_will_show), menub));
        mi->set_submenu(*menu);
        menu->show();
      }
      menu_shell = menu;
    } else
      logError("Passed MenuBase %p does not contain neither Gtk::MenuBar nor Gtk::MenuItem\n", menub);
  } else {
    if (menub->get_parent() && get_accel_group(menub))
      propagate_accel_group(menub, get_accel_group(menub));
  }
  if (menu_shell && item_to_insert)
    menu_shell->insert(*item_to_insert, index);
  else
    logError("Internal error in MenuBase::insert_item()\n");
}
Exemplo n.º 2
0
DebugDialogImpl::DebugDialogImpl()
{
    set_title(_("Messages"));
    set_size_request(300, 400);

#if WITH_GTKMM_3_0
    Gtk::Box *mainVBox = get_content_area();
#else
    Gtk::Box *mainVBox = get_vbox();
#endif

    //## Add a menu for clear()
    Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem(_("_File"), true));
    item->set_submenu(fileMenu);
    menuBar.append(*item);

    item = Gtk::manage(new Gtk::MenuItem(_("_Clear"), true));
    item->signal_activate().connect(sigc::mem_fun(*this, &DebugDialogImpl::clear));
    fileMenu.append(*item);

    item = Gtk::manage(new Gtk::MenuItem(_("Capture log messages")));
    item->signal_activate().connect(sigc::mem_fun(*this, &DebugDialogImpl::captureLogMessages));
    fileMenu.append(*item);
    
    item = Gtk::manage(new Gtk::MenuItem(_("Release log messages")));
    item->signal_activate().connect(sigc::mem_fun(*this, &DebugDialogImpl::releaseLogMessages));
    fileMenu.append(*item);

    mainVBox->pack_start(menuBar, Gtk::PACK_SHRINK);
    

    //### Set up the text widget
    messageText.set_editable(false);
    textScroll.add(messageText);
    textScroll.set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS);
    mainVBox->pack_start(textScroll);

    show_all_children();

    message("ready.");
    message("enable log display by setting ");
    message("dialogs.debug 'redirect' attribute to 1 in preferences.xml");

    handlerDefault = 0;
    handlerGlibmm  = 0;
    handlerAtkmm   = 0;
    handlerPangomm = 0;
    handlerGdkmm   = 0;
    handlerGtkmm   = 0;
}
Exemplo n.º 3
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.º 4
0
HistorySubMenu::HistorySubMenu( const std::string& url_history )
    : Gtk::Menu(),
      m_url_history( url_history )
{
    Gtk::MenuItem* item;

    // メニュー項目作成

    // 履歴クリア
    Gtk::Menu* menu = Gtk::manage( new Gtk::Menu() );
    item = Gtk::manage( new Gtk::MenuItem( "クリアする(_C)", true ) );
    menu->append( *item );
    item->signal_activate().connect( sigc::mem_fun( *this, &HistorySubMenu::slot_clear ) ); 

    item = Gtk::manage( new Gtk::MenuItem( "履歴クリア(_C)", true ) );
    item->set_submenu( *menu );
    append( *item );

    item = Gtk::manage( new Gtk::MenuItem( "サイドバーに全て表示(_S)", true ) );
    append( *item );
    item->signal_activate().connect( sigc::mem_fun( *this, &HistorySubMenu::slot_switch_sideber ) );

    // セパレータ
    item = Gtk::manage( new Gtk::SeparatorMenuItem() );
    append( *item );

    // 履歴項目
    for( int i = 0; i < CONFIG::get_history_size(); ++i ){

        Gtk::Image* image = Gtk::manage( new Gtk::Image() );
        m_vec_images.push_back( image );

        Gtk::Label* label = Gtk::manage( new Gtk::Label( HIST_NONAME ) );
        m_vec_label.push_back( label );

        Gtk::Label *label_motion = Gtk::manage( new Gtk::Label() );
        if( i == 0 ) label_motion->set_text( CONTROL::get_str_motions( CONTROL::RestoreLastTab ) );

        Gtk::HBox* hbox = Gtk::manage( new Gtk::HBox() );
        hbox->set_spacing( SPACING_MENU );
        hbox->pack_start( *image, Gtk::PACK_SHRINK );
        hbox->pack_start( *label, Gtk::PACK_SHRINK );
        hbox->pack_end( *label_motion, Gtk::PACK_SHRINK );

        Gtk::MenuItem* item = Gtk::manage( new Gtk::MenuItem( *hbox ) );
        append( *item );
        item->signal_activate().connect( sigc::bind< int >( sigc::mem_fun( *this, &HistorySubMenu::slot_active ), i ) );
        item->signal_button_press_event().connect( sigc::bind< int >( sigc::mem_fun( *this, &HistorySubMenu::slot_button_press ), i ) );
    }

    // ポップアップメニュー作成
    m_popupmenu.signal_deactivate().connect( sigc::mem_fun( *this, &HistorySubMenu::deactivate ) );

    item = Gtk::manage( new Gtk::MenuItem( "タブで開く" ) );
    item->signal_activate().connect( sigc::mem_fun( *this, &HistorySubMenu::slot_open_history ) );
    m_popupmenu.append( *item );

    item = Gtk::manage( new Gtk::SeparatorMenuItem() );
    m_popupmenu.append( *item );

    item = Gtk::manage( new Gtk::MenuItem( "履歴から削除" ) );
    item->signal_activate().connect( sigc::mem_fun( *this, &HistorySubMenu::slot_remove_history ) );
    m_popupmenu.append( *item );

    item = Gtk::manage( new Gtk::SeparatorMenuItem() );
    m_popupmenu.append( *item );

    item = Gtk::manage( new Gtk::MenuItem( "プロパティ" ) );
    item->signal_activate().connect( sigc::mem_fun( *this, &HistorySubMenu::slot_show_property ) );
    m_popupmenu.append( *item );

    m_popupmenu.show_all_children();
}
Exemplo n.º 5
0
void NotebookApplicationAddin::initialize ()
{
    m_actionGroup = Glib::RefPtr<Gtk::ActionGroup>(Gtk::ActionGroup::create("Notebooks"));
    m_actionGroup->add(
        Gtk::Action::create ("NewNotebookMenuAction", Gtk::Stock::NEW,
                             _("Note_books"),
                             _("Create a new note in a notebook")));

    m_actionGroup->add(
        Gtk::Action::create ("NewNotebookAction", Gtk::Stock::NEW,
                             _("New Note_book..."),
                             _("Create a new notebook")));

    m_actionGroup->add(
        Gtk::Action::create ("NewNotebookNoteAction", Gtk::Stock::NEW,
                             _("_New Note"),
                             _("Create a new note in this notebook")));

    m_actionGroup->add(
        Gtk::Action::create ("OpenNotebookTemplateNoteAction", Gtk::Stock::OPEN,
                             _("_Open Template Note"),
                             _("Open this notebook's template note")));

    m_actionGroup->add(
        Gtk::Action::create ("DeleteNotebookAction", Gtk::Stock::DELETE,
                             _("Delete Note_book"),
                             _("Delete the selected notebook")));

    m_actionGroup->add(
        Gtk::Action::create ("TrayNewNotebookMenuAction", Gtk::Stock::NEW,
                             _("Notebooks"),
                             _("Create a new note in a notebook")));

    ActionManager & am(ActionManager::obj());
    m_notebookUi = am.get_ui()->add_ui_from_string (uixml);

    am.get_ui()->insert_action_group (m_actionGroup, 0);

    Gtk::MenuItem *item = dynamic_cast<Gtk::MenuItem*>(
                              am.get_widget ("/TrayIconMenu/TrayNewNotePlaceholder/TrayNewNotebookMenu"));
    if (item) {
        Gtk::ImageMenuItem *image_item = dynamic_cast<Gtk::ImageMenuItem*>(item);
        if (image_item) {
            image_item->set_image(*manage(new Gtk::Image(m_notebookIcon)));
        }
        m_trayNotebookMenu = manage(new Gtk::Menu());
        item->set_submenu(*m_trayNotebookMenu);

        m_trayNotebookMenu->signal_show()
        .connect(sigc::mem_fun(*this,
                               &NotebookApplicationAddin::on_tray_notebook_menu_shown));
        m_trayNotebookMenu->signal_hide()
        .connect(sigc::mem_fun(*this,
                               &NotebookApplicationAddin::on_tray_notebook_menu_hidden));
    }

    Gtk::ImageMenuItem *imageitem = dynamic_cast<Gtk::ImageMenuItem*>(
                                        am.get_widget ("/MainWindowMenubar/FileMenu/FileMenuNewNotePlaceholder/NewNotebookMenu"));
    if (imageitem) {
        imageitem->set_image(*manage(new Gtk::Image(m_notebookIcon)));
        m_mainWindowNotebookMenu = manage(new Gtk::Menu ());
        imageitem->set_submenu(*m_mainWindowNotebookMenu);

        m_mainWindowNotebookMenu->signal_show()
        .connect(sigc::mem_fun(*this,
                               &NotebookApplicationAddin::on_new_notebook_menu_shown));

        m_mainWindowNotebookMenu->signal_hide()
        .connect(sigc::mem_fun(*this,
                               &NotebookApplicationAddin::on_new_notebook_menu_hidden));
    }
    imageitem = dynamic_cast<Gtk::ImageMenuItem*>(
                    am.get_widget ("/NotebooksTreeContextMenu/NewNotebookNote"));
    if (imageitem) {
        imageitem->set_image(*manage(new Gtk::Image(am.get_new_note())));
    }

    NoteManager & nm(Gnote::obj().default_note_manager());

    for(Note::List::const_iterator iter = nm.get_notes().begin();
            iter != nm.get_notes().end(); ++iter) {
        const Note::Ptr & note(*iter);
        note->signal_tag_added().connect(
            sigc::mem_fun(*this, &NotebookApplicationAddin::on_tag_added));
        note->signal_tag_removed().connect(
            sigc::mem_fun(*this, &NotebookApplicationAddin::on_tag_removed));
    }

    nm.signal_note_added.connect(
        sigc::mem_fun(*this, &NotebookApplicationAddin::on_note_added));
    nm.signal_note_deleted.connect(
        sigc::mem_fun(*this, &NotebookApplicationAddin::on_note_deleted));

    m_initialized = true;
}
Exemplo n.º 6
0
void MainSynthWindow::populateMenu (void)
{
    /* File */
    {
        Gtk::Menu::MenuList &menulist = menuFile_.items();

        menulist.push_back(
            Gtk::Menu_Helpers::MenuElem("_Keyboard",
                                        Gtk::AccelKey("<ctrl>k"),
                                        sigc::mem_fun(*this, &MainSynthWindow::menuKeyboard)));

        menulist.push_back(
            Gtk::Menu_Helpers::MenuElem("_Patch Selector",
                                        Gtk::AccelKey("<ctrl>p"),
                                        sigc::mem_fun(*this, &MainSynthWindow::menuPatchSel)));

        menulist.push_back(
            Gtk::Menu_Helpers::MenuElem("_MIDI Controllers",
                                        Gtk::AccelKey("<ctrl>m"),
                                        sigc::mem_fun(*this, &MainSynthWindow::menuMidiMap)));

        menulist.push_back(Gtk::Menu_Helpers::SeparatorElem());

        menulist.push_back(
            Gtk::Menu_Helpers::MenuElem("_Quit",
                                        Gtk::AccelKey("<ctrl>q"),
                                        sigc::mem_fun(*this, &MainSynthWindow::menuQuit)));
    }

#ifdef HAVE_JACK
    /* JACK */
    if (dynamic_cast<gthJackAudio*>(audio_) != NULL)
    {
        gthPrefs *prefs = gthPrefs::instance();
        Gtk::Menu::MenuList &menulist = menuJack_.items();
        Gtk::CheckMenuItem *elem;
        sigc::slot0<void> autoslot =
            sigc::mem_fun(*this, &MainSynthWindow::menuJackAuto);
        string** vals;
        bool sel;
        
        menulist.push_back(
            Gtk::Menu_Helpers::MenuElem("_Connect to JACK now",
                sigc::mem_fun(*this, &MainSynthWindow::menuJackTry)));

        menulist.push_back(
            Gtk::Menu_Helpers::MenuElem("_Disconnect from JACK",
                sigc::mem_fun(*this, &MainSynthWindow::menuJackDis)));

        menulist.back().set_sensitive(false);

        menulist.push_back(Gtk::Menu_Helpers::SeparatorElem());

        menulist.push_back(
            Gtk::Menu_Helpers::CheckMenuElem ("_Auto-connect to JACK",
                autoslot));

        elem = (Gtk::CheckMenuItem*)&menulist.back();
    
        vals = prefs->Get("autoconnect");
        sel = !!(vals && *vals[0] == "true");
        elem->set_active(sel);
    }
#endif /* HAVE_JACK */
    
    /* Help */
    {
        Gtk::Menu::MenuList &menulist = menuHelp_.items();

        menulist.push_back(
            Gtk::Menu_Helpers::MenuElem("_About",
                                        sigc::mem_fun(
                                            *this, &MainSynthWindow::menuAbout)
                ));
    }

    /* add the menus to the menubar */
    {
        Gtk::Menu::MenuList &menulist = menuBar_.items();

        menulist.push_back(Gtk::Menu_Helpers::MenuElem("_File",
                                                       menuFile_));

#ifdef HAVE_JACK
        if (dynamic_cast<gthJackAudio*>(audio_) != NULL)
            menulist.push_back(Gtk::Menu_Helpers::MenuElem("_JACK",
                                                        menuJack_));
#endif
        
        Gtk::MenuItem *helpMenu = manage(new Gtk::MenuItem("_Help", true));
        helpMenu->set_submenu(menuHelp_);
        helpMenu->set_right_justified();
        menulist.push_back(*helpMenu);
    }
}