//------------------------------------------------------------------------------
std::string mforms::gtk::MenuItemImpl::get_title(mforms::MenuItem *item) {
  std::string ret;
  Gtk::MenuItem *mi = cast<Gtk::MenuItem *>(item->get_data_ptr());
  if (mi)
    ret = mi->get_label();
  return ret;
}
void ObjectsTreeView::init_popup_menu() {
  Gtk::MenuItem* item;

  item = Gtk::manage(new Gtk::MenuItem("Remove", true));
  item->signal_activate().connect(
    sigc::mem_fun(*this, &ObjectsTreeView::on_menu_popup_remove) );
  _menu.append(*item);

  item = Gtk::manage(new Gtk::MenuItem("Translate...", true));
  item->signal_activate().connect(
    sigc::mem_fun(*this, &ObjectsTreeView::on_menu_popup_translate) );
  _menu.append(*item);

  item = Gtk::manage(new Gtk::MenuItem("Scale...", true));
  item->signal_activate().connect(
    sigc::mem_fun(*this, &ObjectsTreeView::on_menu_popup_scale) );
  _menu.append(*item);

  item = Gtk::manage(new Gtk::MenuItem("Rotate...", true));
  item->signal_activate().connect(
    sigc::mem_fun(*this, &ObjectsTreeView::on_menu_popup_rotate) );
  _menu.append(*item);

  _menu.accelerate(*this);
  _menu.show_all(); //Show all menu items when the menu pops up

  signal_button_press_event().connect(sigc::mem_fun(*this, &ObjectsTreeView::on_button_press_event), false);
}
//------------------------------------------------------------------------------
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;
}
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");
}
//------------------------------------------------------------------------------
void mforms::gtk::MenuItemImpl::remove_item(mforms::MenuBase *menu, mforms::MenuItem *item) {
  Gtk::MenuShell *menu_shell = cast<Gtk::MenuShell *>(menu->get_data_ptr());
  if (!menu_shell) {
    Gtk::MenuItem *mi = cast<Gtk::MenuItem *>(menu->get_data_ptr());
    if (mi) {
      if (mi->has_submenu())
        menu_shell = mi->get_submenu();
      else
        logError("Requesting to remove MenuItem from Menu with no sub menu\n");
    } else
      logError("Passed MenuBase %p does not contain neither Gtk::MenuBar nor Gtk::MenuItem\n", menu);
  }

  Gtk::MenuItem *item_to_remove = item ? cast<Gtk::MenuItem *>(item->get_data_ptr()) : 0;
  if (menu_shell) {
    if (item_to_remove)
      menu_shell->remove(*item_to_remove); // May not work needs to be tested
    else {
      typedef Glib::ListHandle<Gtk::Widget *> WList;
      WList list = menu_shell->get_children();
      for (base::const_range<WList> it(list); it; ++it)
        menu_shell->remove(*(*it));
    }
  }
}
Exemple #6
0
PrefWindow::PrefWindow(GtkWindow* base, const Glib::RefPtr<Gtk::Builder>& builder) : 
	Gtk::Window(base)
{
	windowState.Reset();
	// initializing menu items
	Gtk::MenuItem* item = 0;
	builder->get_widget("menuGameQuit", item);
	PrefAssert( item != 0 );
	item->signal_activate().connect(sigc::ptr_fun(&PrefSlots::quit));
	item = 0;
	builder->get_widget("menuHelpAbout", item);
	PrefAssert( item != 0 );
	item->signal_activate().connect(sigc::ptr_fun(&PrefSlots::about));
	item = 0;
	builder->get_widget("menuGameNew", item);
	PrefAssert( item != 0 );
	item->signal_activate().connect(sigc::ptr_fun(&PrefSlots::startGameWithBots));
	// initializing status bar
	Gtk::Statusbar* _statusbar = 0;
	builder->get_widget("mainWindowStatusBar", _statusbar);
	PrefAssert( _statusbar != 0 );
	statusbar = Glib::RefPtr<Gtk::Statusbar>(_statusbar);
	// initializing bidding dialog
	BiddingDialog* _biddingDialog = 0;
	builder->get_widget_derived("biddingWindow", _biddingDialog);
	PrefAssert( _biddingDialog != 0 );
	biddingDialog = Glib::RefPtr<BiddingDialog>( _biddingDialog );
	PrefView* _gameView = 0;
	builder->get_widget_derived("gameView", _gameView);
	PrefAssert( _gameView != 0 );
	gameView = Glib::RefPtr<PrefView>( _gameView );
}
Exemple #7
0
void DocumentView::populate_popup(Gtk::Menu* menu) {
    std::set<Glib::ustring> items_to_remove = {
        "_Undo",
        "_Redo",
        "_Delete",
        "C_hange Case",
        "Select _All"
    };

    Gtk::MenuItem* comment = Gtk::manage(new Gtk::MenuItem("Comment Lines"));
    Gtk::MenuItem* uncomment = Gtk::manage(new Gtk::MenuItem("Uncomment Lines"));

    //menu->add(*Gtk::manage(new Gtk::SeparatorMenuItem()));
    menu->add(*comment);
    menu->add(*uncomment);
    menu->show_all();

    for(Gtk::Widget* item: menu->get_children()) {
        Gtk::MenuItem* itm = dynamic_cast<Gtk::MenuItem*>(item);
        if(itm) {
            auto label = itm->get_label();
            if(label == "") {
                itm->hide(); //Hide separators
            } else {
                std::cout << label << std::endl;
                if(items_to_remove.count(label)) {
                    itm->hide();
                }
            }
        }
    }
}
void MainSynthWindow::toggleConnects (void)
{
    Gtk::MenuItem *me = (Gtk::MenuItem *)&menuJack_.items()[0];
    Gtk::MenuItem *dis = (Gtk::MenuItem *)&menuJack_.items()[1];
    bool c = me->is_sensitive();
    me->set_sensitive(!c);
    dis->set_sensitive(c);
}
Exemple #9
0
//------------------------------------------------------------------------------
void mforms::gtk::MenuImpl::set_item_enabled(Menu *self, int i, bool flag)
{
    MenuImpl* menu = self->get_data<MenuImpl>();
    if (menu)  {
        Gtk::MenuItem *item = menu->item_at(i);
        if (item)
            item->set_sensitive(flag);
    }
}
Exemple #10
0
PlaylistViewer::PlaylistViewer()
{
  //Create the Tree model:
  m_refTreeModel = Gtk::ListStore::create(m_Columns);
  set_model(m_refTreeModel);

 // Fill the TreeView's model
 // Gtk::TreeModel::Row row = *(m_refTreeModel->append());
/*
  row[m_Columns.m_col_trackNum] = 1;
  row[m_Columns.m_col_trackName] = "right-click on this";
  row[m_Columns.m_col_trackPath] = "right-click on this";

  row = *(m_refTreeModel->append());
  row[m_Columns.m_col_trackNum]= 2;
  row[m_Columns.m_col_trackName] = "or this";
  row[m_Columns.m_col_trackPath] = "right-click on this";

  row = *(m_refTreeModel->append());
  row[m_Columns.m_col_trackNum] = 3;
  row[m_Columns.m_col_trackName] = "or this, for a popup context menu";
  row[m_Columns.m_col_trackPath] = "right-click on this";
*/

// master plan is to run through a vector to populate values


 
  //Add the TreeView's view columns:
  append_column("Track", m_Columns.m_col_trackNum);
  append_column("Name", m_Columns.m_col_trackName);
  append_column("Path", m_Columns.m_col_trackPath);

  //Fill popup menu:
  Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem("_Play", true));
  item->signal_activate().connect(
    sigc::mem_fun(*this, &PlaylistViewer::on_menu_file_popup_generic) );
  m_Menu_Popup.append(*item);
    
  item = Gtk::manage(new Gtk::MenuItem("_Queue", true));
  item->signal_activate().connect(
    sigc::mem_fun(*this, &PlaylistViewer::on_menu_file_popup_generic) );
  m_Menu_Popup.append(*item);
    
  item = Gtk::manage(new Gtk::MenuItem("_Info", true));
  item->signal_activate().connect(
    sigc::mem_fun(*this, &PlaylistViewer::on_menu_file_popup_generic) );
  m_Menu_Popup.append(*item);

  m_Menu_Popup.accelerate(*this);
  m_Menu_Popup.show_all(); //Show all menu items when the menu pops up

#ifndef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
  signal_button_press_event()
    .connect(sigc::mem_fun(*this, &PlaylistViewer::on_button_press_event), false);
#endif
}
Exemple #11
0
void Menu::setTaskIsSelected(bool show)
{
	std::list<Gtk::MenuItem*>::iterator iter;
	for (iter = taskIDDependentMenus.begin(); iter != taskIDDependentMenus.end(); ++iter)
	{
		Gtk::MenuItem* menuItem = *iter;
		menuItem->set_sensitive(show);
	}

}
//------------------------------------------------------------------------------
static void propagate_accel_group(mforms::MenuBase *item, Glib::RefPtr<Gtk::AccelGroup> agroup) {
  Gtk::MenuItem *mi = cast<Gtk::MenuItem *>(item->get_data_ptr());
  if (mi && mi->has_submenu())
    mi->get_submenu()->set_accel_group(agroup);

  for (int i = item->item_count() - 1; i >= 0; --i) {
    mforms::MenuItem *it = item->get_item(i);
    if (!it->get_shortcut().empty())
      mforms::gtk::MenuItemImpl::set_shortcut(it, it->get_shortcut());
    propagate_accel_group(it, agroup);
  }
}
Exemple #13
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;
}
Exemple #14
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;
}
Exemple #15
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);
    }
Exemple #16
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;
}
Exemple #17
0
bool SeriesMenu::get_index(const Gtk::MenuItem& item, int& index) {
	Gtk::Menu_Helpers::MenuList::iterator i = items().begin();
	index = 0;
	for(; i != items().end(); i++) {
		if(i->gobj() == item.gobj()) {
			return true;
		}
		index++;
	}
	return false;
}
TreeViewGoods::TreeViewGoods()
{
    /* Create tree */
    treeRecords = Gtk::ListStore::create( treeColumns );
    set_model( treeRecords );

    /* Create columns */
    append_column( "Код", treeColumns.id );
    append_column( "Наименование", treeColumns.name );
    append_column( "Цена", treeColumns.price );
    append_column( "Ед.Изм.", treeColumns.item );

    /* Create popup menu */
    Gtk::MenuItem* item = Gtk::manage( new Gtk::MenuItem( "Подробнее" ) );
    item->signal_activate().connect( sigc::mem_fun( *this, &TreeViewGoods::on_menu_file_popup_generic ) );
    menuPopup.append( *item );
    menuPopup.accelerate( *this );
    menuPopup.show_all();

    /* Connect press event signal (mouse clicks) */
    signal_button_press_event().connect( sigc::mem_fun( *this, &TreeViewGoods::on_button_press_event ), false );
}
Exemple #19
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;
}
Exemple #20
0
ListView::ListView() : Gtk::TreeView()
{
    // поиграемся с TreeView
    // создаём модель
    m_refTreeModel = Gtk::ListStore::create( m_Columns );
    set_model( m_refTreeModel );
    // Теперь добавляем столбцы для отображения
    append_column( "Name", m_Columns.m_col_name );
    append_column( "Size", m_Columns.m_col_size );
    append_column( "User/Group", m_Columns.m_col_users );
    append_column( "Permission", m_Columns.m_col_permission );
    append_column( "Type", m_Columns.m_col_type );
    append_column( "Modified", m_Columns.m_col_modified );

    //Set the sort column of the Tree model:
    m_refTreeModel->set_sort_column(0, Gtk::SORT_ASCENDING);

    Gtk::TreeView::Column* pColumn;
    pColumn = get_column(0);
    if( pColumn )
        pColumn->set_sort_column( m_Columns.m_col_name );
    pColumn = get_column(1);
    if( pColumn )
        pColumn->set_sort_column( m_Columns.m_col_size );
    pColumn = get_column(2);
    if( pColumn )
        pColumn->set_sort_column( m_Columns.m_col_users );
    pColumn = get_column(3);
    if( pColumn )
        pColumn->set_sort_column( m_Columns.m_col_permission );
    pColumn = get_column(4);
    if( pColumn )
        pColumn->set_sort_column( m_Columns.m_col_type );
    pColumn = get_column(5);
    if( pColumn )
        pColumn->set_sort_column( m_Columns.m_col_modified );
    //Fill popup menu:
      Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem("_Open", true));
      item->signal_activate().connect(
        sigc::mem_fun(*this, &ListView::on_menu_file_popup_generic) );
      m_Menu_Popup.append(*item);

      item = Gtk::manage(new Gtk::MenuItem("_Open with…", true));
      item->signal_activate().connect(
        sigc::mem_fun(*this, &ListView::on_menu_file_popup_generic) );
      m_Menu_Popup.append(*item);

      item = Gtk::manage(new Gtk::MenuItem("_Properties", true));
      item->signal_activate().connect(
        sigc::mem_fun(*this, &ListView::on_menu_file_popup_generic) );
      m_Menu_Popup.append(*item);

      m_Menu_Popup.accelerate(*this);
      m_Menu_Popup.show_all(); //Show all menu items when the menu pops up

      signal_button_press_event()
        .connect(sigc::mem_fun(*this, &ListView::on_button_press_event), false);

    Navigator nvg;
    show_file_list( nvg.get_file_list() );
}
Exemple #21
0
AppWindow::AppWindow() {
  m_viewer = new Viewer(this);

  set_title("CS488 Assignment Two, by Alex Klen");

  // Application Menu.
  Gtk::MenuItem *reset = Gtk::manage(new Gtk::MenuItem("_Reset", true));
  Gtk::MenuItem *quit = Gtk::manage(new Gtk::MenuItem("_Quit", true));

  reset->signal_activate().connect(sigc::mem_fun(*this, &AppWindow::reset_view));
  quit->signal_activate().connect(sigc::mem_fun(*this, &AppWindow::hide));

  add_accelerator(reset, 'a');
  add_accelerator(quit, 'q');

  m_menu_app.items().push_back(*reset);
  m_menu_app.items().push_back(*quit);

  // Mode Menu.
  const char shortcuts[] = {
    'o', 'n', 'p', 'r', 't', 's', 'v'
  };
  const std::string names[] = {
    "R_otate View",
    "Tra_nslate View",
    "_Perspective",
    "_Rotate Model",
    "_Translate Model",
    "_Scale Model",
    "_Viewport"
  };

  // Create and wire signals for radio buttons for each mode.
  Gtk::RadioMenuItem::Group view_mode_group;
  sigc::slot1<void, Viewer::Mode> view_mode_slot = sigc::mem_fun(*m_viewer, &Viewer::set_mode);

  for (int mode = 0; mode < Viewer::NUM_MODES; mode++) {
    Gtk::RadioMenuItem *rb = Gtk::manage(new Gtk::RadioMenuItem(view_mode_group, names[mode], true));
    add_accelerator(rb, shortcuts[mode]);
    rb->signal_activate().connect(sigc::bind(view_mode_slot, (Viewer::Mode) mode));
    m_menu_mode.items().push_back(*rb);
  }

  // Set up the menu bar
  m_menubar.items().push_back(Gtk::Menu_Helpers::MenuElem("_Application", m_menu_app));
  m_menubar.items().push_back(Gtk::Menu_Helpers::MenuElem("_Mode", m_menu_mode));

  // Select default radio button.
  m_menu_mode.items()[Viewer::DEFAULT_MODE].activate();

  // Pack in our widgets

  // First add the vertical box as our single "top" widget
  add(m_vbox);

  // Put the menubar on the top, and make it as small as possible
  m_vbox.pack_start(m_menubar, Gtk::PACK_SHRINK);

  // Put the viewer below the menubar. pack_start "grows" the widget
  // by default, so it'll take up the rest of the window.
  m_viewer->set_size_request(600, 600);
  m_vbox.pack_start(*m_viewer);

  m_vbox.pack_start(m_main_label, false, false);

  show_all();
}
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);
    }

}
Exemple #23
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);
    }
}
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;
}
Exemple #25
0
MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& refGlade)
: Gtk::Window(cobject),
  builder(refGlade)
{
	Gtk::ComboBoxText *cbt = NULL;
	Gtk::MenuItem* menuitem = NULL;
	Gtk::TextView *log;

	this->s = new CSetup();
	this->smtp = NULL;
	this->imap = NULL;
	this->pop = NULL;
	this->http = NULL;

	this->nb = NULL;

	builder->get_widget("main_menu_quit", menuitem);
	if(menuitem)
		menuitem->signal_activate().connect( sigc::mem_fun(*this, &MainWindow::OnMenuQuit) );

	builder->get_widget("main_menu_about", menuitem);
	if(menuitem)
		menuitem->signal_activate().connect( sigc::mem_fun(*this, &MainWindow::OnMenuAbout) );

	builder->get_widget("main_menu_preferences", menuitem);
	if(menuitem)
		menuitem->signal_activate().connect( sigc::mem_fun(*this, &MainWindow::OnMenuPreferences) );


	/* connect setup with history lists */
	builder->get_widget("http_server_name_combo", cbt);
	s->AttachList((char *)"http", cbt);

	/* connect setup with history lists */
	builder->get_widget("smtp_server_name_combo", cbt);
	s->AttachList((char *)"smtp", cbt);

	/* connect setup with history lists */
	builder->get_widget("imap_server_name_combo", cbt);
	s->AttachList((char *)"imap", cbt);

	/* connect setup with history lists */
	builder->get_widget("pop_server_name_combo", cbt);
	s->AttachList((char *)"pop", cbt);

	s->FillupLists();

	builder->get_widget("pd_notebook", this->nb);
	if (this->nb) this->nb->set_current_page(s->GetTab());

	builder->get_widget("log", log);

	this->smtp = new CSMTP(builder);
	this->imap = new CIMAP(builder);
	this->pop = new CPOP(builder);
	this->http = new CHTTP(builder);

	if (log) {
		this->smtp->SetLog(log);
		this->imap->SetLog(log);
		this->pop->SetLog(log);
		this->http->SetLog(log);
	}
}
//------------------------------------------------------------------------------
void mforms::gtk::MenuItemImpl::set_title(mforms::MenuItem *item, const std::string &label) {
  Gtk::MenuItem *mi = cast<Gtk::MenuItem *>(item->get_data_ptr());
  if (mi)
    mi->set_label(label);
}
Exemple #27
0
/**
 * The menu builder method.
 */
void MenuWidget::buildMenu()
{
	//Gtk::Widget* menuBar;
	//std::string name;
	//std::map<int, std::map<std::string, std::string>>::iterator iterator;
	//Glib::ustring ui_string;
	//
	//// Build the action group and the UI from the given items.
	//for (iterator = this->m_Items.begin(); iterator != this->m_Items.end(); iterator++) {
	//	name = iterator->second["name"];
	//
	//	// On menu button click, we want to open a new tab into the notebook.
	//	this->m_ActionGroup->add(
	//		Gtk::Action::create(name, name),
	//		sigc::bind(sigc::mem_fun(*this, &MenuWidget::onMenuAccess), name, iterator->second["file"])
	//		);
	//
	//	ui_string += "<toolitem action='" + name + "' />";
	//}
	//
	//// Set action group.
	//this->m_UIManager->insert_action_group(this->m_ActionGroup);
	//
	//// Load the defined UI.
	//ui_string =
	//	"<ui>"
	//	"  <toolbar name='MenuBar'>"
	//	+ ui_string +
	//	"  </toolbar>"
	//	"</ui>";
	//this->m_UIManager->add_ui_from_string(ui_string);
	//
	//// Fetch the menu bar and orient it vertically.
	//menuBar = this->m_UIManager->get_widget("/MenuBar");
	//menuBar->set_property("orientation", Gtk::ORIENTATION_VERTICAL);
	//
	//// Add the menu bar and the accel_group to the window.
	//this->m_Window->add_accel_group(this->m_UIManager->get_accel_group());
	//this->m_Container->add(m_WorkspaceNotebook);

	// Create the passes workspace item
	m_TableColumnRecord.add(m_TableColumn);

	m_PassTableTreeModel = Gtk::TreeStore::create(m_TableColumnRecord);
	m_PassTable.set_model(m_PassTableTreeModel);
	
	m_PassTable.append_column("Passes", m_TableColumn);
	m_PassTable.set_headers_visible(false);
	m_PassTable.signal_row_activated().connect(sigc::mem_fun(*this, &MenuWidget::OnPassItemActivated));

	m_PassTable.add_events(Gdk::BUTTON_PRESS_MASK);
	m_PassTable.signal_button_press_event().connect_notify(sigc::mem_fun(*this, &MenuWidget::OnPassWindowMenuPopup));
	
	// Create the constant table workspace item
	m_ConstantTableTreeModel = Gtk::TreeStore::create(m_TableColumnRecord);
	m_ConstantTable.set_model(m_ConstantTableTreeModel);

	m_ConstantTable.append_column("Constant Table", m_TableColumn);
	m_ConstantTable.set_headers_visible(false);
	m_ConstantTable.signal_row_activated().connect(sigc::mem_fun(*this, &MenuWidget::OnConstantItemActivated));

	// Build workspace notebook
	m_WorkspaceNotebook.append_page(m_PassTable, "Passes");
	m_WorkspaceNotebook.append_page(m_ConstantTable, "Constants");

	// Populate popup menu
	Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem("Add pass above", false));
	item->signal_activate().connect(sigc::mem_fun(*this, &MenuWidget::OnPassAddAbove));
	m_PassPopupMenu.append(*item);

	item = Gtk::manage(new Gtk::MenuItem("Add pass below", false));
	item->signal_activate().connect(sigc::mem_fun(*this, &MenuWidget::OnPassAddBelow));
	m_PassPopupMenu.append(*item);

	item = Gtk::manage(new Gtk::MenuItem("Remove pass", false));
	item->signal_activate().connect(sigc::mem_fun(*this, &MenuWidget::OnPassRemove));
	m_PassPopupMenu.append(*item);

	item = Gtk::manage(new Gtk::MenuItem("Add render target", false));
	item->signal_activate().connect(sigc::mem_fun(*this, &MenuWidget::OnRenderTargetAdd));
	m_PassPopupMenu.append(*item);

	item = Gtk::manage(new Gtk::MenuItem("Remove render target", false));
	item->signal_activate().connect(sigc::mem_fun(*this, &MenuWidget::OnRenderTargetRemove));
	m_PassPopupMenu.append(*item);

	m_PassPopupMenu.accelerate(m_PassTable);
	m_PassPopupMenu.show_all();

	// Add the notebook
	m_Container->add(m_WorkspaceNotebook);

	// Init dialog for adding passes
	m_PassAddDialog.set_modal();
	m_PassAddDialog.get_vbox()->pack_start(*Gtk::manage(new Gtk::Label("Pass name:")));
	m_PassAddDialog.get_vbox()->pack_end(m_PassAddName);
	m_PassAddDialog.add_button(GTK_STOCK_OK, Gtk::RESPONSE_OK);
	m_PassAddDialog.get_vbox()->show_all();
}
Exemple #28
0
PaintWindow::PaintWindow() {
  set_title("488 Paint");

  using Gtk::Menu_Helpers::MenuElem;

  // Set up the application menu.
  Gtk::MenuItem *clear = Gtk::manage(new Gtk::MenuItem("_Clear", true));
  Gtk::MenuItem *quit = Gtk::manage(new Gtk::MenuItem("_Quit", true));

  clear->signal_activate().connect(sigc::mem_fun(*this, &PaintWindow::clear));
  quit->signal_activate().connect(sigc::mem_fun(*this, &PaintWindow::hide));

  clear->add_accelerator("activate", get_accel_group(), 'c', (Gdk::ModifierType) 0, Gtk::ACCEL_VISIBLE);
  clear->add_accelerator("activate", get_accel_group(), 'c', Gdk::SHIFT_MASK, Gtk::ACCEL_VISIBLE);
  quit->add_accelerator("activate", get_accel_group(), 'q', (Gdk::ModifierType) 0, Gtk::ACCEL_VISIBLE);
  quit->add_accelerator("activate", get_accel_group(), 'q', Gdk::SHIFT_MASK, Gtk::ACCEL_VISIBLE);

  m_menu_app.items().push_back(*clear);
  m_menu_app.items().push_back(*quit);

  // Set up the tools menu
  //
  // We're going to be connecting a bunch of menu entries to the same
  // function. So, we put a slot corresponding to that function in
  // mode_slot.
  //
  // The type shows that this slot returns void (nothing, and takes
  // one argument, a PaintCanvas::Mode.
  sigc::slot1<void, PaintCanvas::Mode> mode_slot = 
    sigc::mem_fun(m_canvas, &PaintCanvas::set_mode);

  // Now we set up the actual tools. SigC::bind takes a slot and makes
  // a new slot with one fewer parameter than the one passed to it,
  // and "binds in" the constant value passed.
  //
  // In our case we take the reference to PaintCanvas::set_mode we
  // declared above, and bind in the appropriate mode, making a slot
  // that calls set_mode with the given mode (line/oval/rectangle).

  Gtk::RadioMenuItem::Group tool_group;
  Gtk::RadioMenuItem *rb_line = Gtk::manage(new Gtk::RadioMenuItem(tool_group, "_Line", true));
  Gtk::RadioMenuItem *rb_oval = Gtk::manage(new Gtk::RadioMenuItem(tool_group, "_Oval", true));
  Gtk::RadioMenuItem *rb_rectangle = Gtk::manage( new Gtk::RadioMenuItem(tool_group, "_Rectangle", true));

  rb_line->add_accelerator("activate", get_accel_group(), 'l', (Gdk::ModifierType) 0, Gtk::ACCEL_VISIBLE);
  rb_line->add_accelerator("activate", get_accel_group(), 'l', Gdk::SHIFT_MASK, Gtk::ACCEL_VISIBLE);
  rb_oval->add_accelerator("activate", get_accel_group(), 'o', (Gdk::ModifierType) 0, Gtk::ACCEL_VISIBLE);
  rb_oval->add_accelerator("activate", get_accel_group(), 'o', Gdk::SHIFT_MASK, Gtk::ACCEL_VISIBLE);
  rb_rectangle->add_accelerator("activate", get_accel_group(), 'r', (Gdk::ModifierType) 0, Gtk::ACCEL_VISIBLE);
  rb_rectangle->add_accelerator("activate", get_accel_group(), 'r', Gdk::SHIFT_MASK, Gtk::ACCEL_VISIBLE);

  rb_line->signal_activate().connect(sigc::bind( mode_slot, PaintCanvas::DRAW_LINE));
  rb_oval->signal_activate().connect(sigc::bind( mode_slot, PaintCanvas::DRAW_OVAL));
  rb_rectangle->signal_activate().connect(sigc::bind( mode_slot, PaintCanvas::DRAW_RECTANGLE));

  m_menu_tools.items().push_back(*rb_line);
  m_menu_tools.items().push_back(*rb_oval);
  m_menu_tools.items().push_back(*rb_rectangle);

  // Colour menu.
  sigc::slot1<void, Gdk::Color> colour_slot =
    sigc::mem_fun(m_canvas, &PaintCanvas::set_colour);

  Gdk::Color black, red, green, blue;
  black.set("black");
  red.set("red");
  green.set("green");
  blue.set("blue");

  Gtk::RadioMenuItem::Group colour_group;
  Gtk::RadioMenuItem *rb_black = Gtk::manage(new Gtk::RadioMenuItem(colour_group, "Blac_k", true));
  Gtk::RadioMenuItem *rb_red = Gtk::manage(new Gtk::RadioMenuItem(colour_group, "_Red", true));
  Gtk::RadioMenuItem *rb_green = Gtk::manage(new Gtk::RadioMenuItem(colour_group, "_Green", true));
  Gtk::RadioMenuItem *rb_blue = Gtk::manage(new Gtk::RadioMenuItem(colour_group, "_Blue", true));

  rb_black->signal_activate().connect(sigc::bind(colour_slot, black));
  rb_red->signal_activate().connect(sigc::bind(colour_slot, red));
  rb_green->signal_activate().connect(sigc::bind(colour_slot, green));
  rb_blue->signal_activate().connect(sigc::bind(colour_slot, blue));

  m_menu_colours.items().push_back(*rb_black);
  m_menu_colours.items().push_back(*rb_red);
  m_menu_colours.items().push_back(*rb_green);
  m_menu_colours.items().push_back(*rb_blue);

  // Set up the help menu
  m_menu_help.items().push_back(MenuElem("_Line Help",
        sigc::mem_fun(*this, &PaintWindow::help_line)));
  m_menu_help.items().push_back(MenuElem("_Oval Help",
        sigc::mem_fun(*this, &PaintWindow::help_oval)));
  m_menu_help.items().push_back(MenuElem("_Rectangle Help",
        sigc::mem_fun(*this, &PaintWindow::help_rectangle)));

  // Set up the menu bar
  m_menubar.items().push_back(Gtk::Menu_Helpers::MenuElem("_Application", m_menu_app));
  m_menubar.items().push_back(Gtk::Menu_Helpers::MenuElem("_Tools", m_menu_tools));
  m_menubar.items().push_back(Gtk::Menu_Helpers::MenuElem("_Colours", m_menu_colours));
  m_menubar.items().push_back(Gtk::Menu_Helpers::MenuElem("_Help", m_menu_help));
  m_menubar.items().back().set_right_justified(true);

  // Pack in our widgets

  // First add the vertical box as our single "top" widget
  add(m_vbox);

  // Put the menubar on the top, and make it as small as possible
  m_vbox.pack_start(m_menubar, Gtk::PACK_SHRINK);

  // Put the canvas below the menubar. pack_start "grows" the widget
  // by default, so it'll take up the rest of the window.
  m_canvas.set_size_request(300, 300);
  m_vbox.pack_start(m_canvas);

  quit_button.set_label("Quit");
  m_vbox.pack_start(quit_button);
  quit_button.signal_clicked().connect(sigc::mem_fun(*this, &PaintWindow::hide));

  show_all();
}
Exemple #29
0
int common___::proc__(std::deque<Glib::ustring>* p,char*buf,long siz,char**addr_ret,void*shangji,void*ce) {
	const Glib::ustring& p0=(*p)[0];

	if(p0=="剪贴板"){
		if(siz==-1)return 1;
		Glib::RefPtr<Gtk::Clipboard> cb = Gtk::Clipboard::get();
		if(p->size()>1)
			cb->set_text((*p)[1].c_str());
		else
			*addr_ret=dup__(cb->wait_for_text().c_str());
		return 1;
	}
	if(p0=="全屏"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,1);
		if(!w)
			return 1;
		w->fullscreen();
		return 1;
	}
	if(p0=="取消全屏"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,1);
		if(!w)
			return 1;
		w->unfullscreen();
		return 1;
	}
	if(p0=="置顶"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,1);
		if(!w)
			return 1;
		w->set_keep_above(true);
		return 1;
	}
	if(p0=="取消置顶"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,1);
		if(!w)
			return 1;
		w->set_keep_above(false);
		return 1;
	}
	if(p0=="无边框"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,1);
		if(!w)
			return 1;
		w->set_decorated(false);
		return 1;
	}
	if(p0=="跳过任务栏"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,1);
		if(!w)
			return 1;
		w->set_skip_taskbar_hint(true);
		return 1;
	}
	if(p0=="窗口活动"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,1);
		if(!w)
			return 1;
		cpy__(buf,w->property_is_active(),siz);
		return 1;
	}
	if(p0=="图标"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,2);
		if(!w)
			return 1;
		if(p->size()>1){
			const Glib::ustring& p1=(*p)[1];
			w->set_icon_name(p1);
			Glib::RefPtr<Gdk::Pixbuf> pb=Gdk::Pixbuf::create_from_file(p1);
			if(pb)
				w->set_icon(pb);
		}else
			cpy__(buf,w->get_icon_name().c_str(),siz);
		return 1;
	}

	if(p->size()<2){
		return 0;
	}
	const Glib::ustring& p1=(*p)[1];

	Gtk::Entry* e;
	Gtk::Label* l;
	Gtk::Button* b;
	Gtk::ToolButton* tb;
	Gtk::TextView* tv;
	Gtk::Notebook* n;
	Gtk::Bin* bI;
	Gtk::Widget* w;
	Gtk::Statusbar* sB;
	Gtk::FileChooserButton* fcb;
	Gtk::ToggleButton* tOb;//CheckButton RadioButton
	Gtk::ToggleToolButton*ttb;
	//Gtk::RadioButtonGroup* rbg;
	Gtk::MenuItem* mi;
	Gtk::CheckMenuItem* cmi;
	Gtk::SpinButton* sb;

	if(p0=="窗口标题"){
		if(siz==-1)return 1;
		Gtk::Window* w1;
		if(p1=="")
			w1=sh_->main_win_;
		else{
			sh_->builder_->get_widget(p1, w);
			if(!w){
				d_(sh_,err_show_wufa_,2,p,1);
				return 1;
			}
			w1=(Gtk::Window*)w;
		}
		if(p->size()<3){
			cpy__(buf,w1->get_title().c_str(),siz);
		}else{
			w1->set_title((*p)[2]);
		}
		return 1;
	}

	if(p0=="内容"){
		if(siz==-1)return 1;
		Glib::ustring text;
		bool read=false;
		int start=2;
		if(p->size()>2&&(*p)[2]=="读取"){
			read=true;
			start=3;
		}
		for(size_t i=start;i<p->size();i++){
			if((*p)[i]=="源码")
				text+=sh_->src_;
			else{
				if(read){
					string name=sh_->ui_file_;
					size_t i1=name.rfind('/');
					if(i1==string::npos)
						i1=name.rfind('\\');
					if(i1!=string::npos)
						name=name.substr(0,i1+1);
					name+=(*p)[i];
					file_get__(name.c_str(),text);
				}else
					text+=(*p)[i];
			}
		}
		if(p1=="源码"){
			if(p->size()>2)
				sh_->src_=text;
			else
				*addr_ret=dup__(sh_->src_.c_str());
			return 1;
		}else{
			sh_->builder_->get_widget(p1, sb);
			if(sb){
				if(p->size()>2){
					float f=0;
					sscanf(text.c_str(),"%f",&f);
					sb->set_value(f);
					return 1;
				}
			}
			sh_->builder_->get_widget(p1, e);
			if(e){
				if(p->size()<3){
					*addr_ret=dup__(e->get_text().c_str());
				}else{
					e->set_text(text);
				}
				return 1;
			}
			sh_->builder_->get_widget(p1, l);
			if(l){
				if(p->size()<3){
					*addr_ret=dup__(l->get_text().c_str());
				}else{
					l->set_markup(text);
				}
				return 1;
			}
			sh_->builder_->get_widget(p1, tv);
			if(tv){
				if(p->size()<3){
					*addr_ret=dup__(tv->get_buffer()->get_text().c_str());
				}else{
					tv->get_buffer()->set_text(text);
				}
				return 1;
			}
			sh_->builder_->get_widget(p1, fcb);
			if(fcb){
				if(p->size()<3){
					*addr_ret=dup__(fcb->get_filename().c_str());
				}else{
					fcb->set_filename(text);

					  /*GtkFileChooser *chooser=(GtkFileChooser *)fcb->gobj();
					  const gchar    *filename=text.c_str();
					  gtk_file_chooser_unselect_all (chooser);
					  //gtk_file_chooser_select_filename (chooser, filename);
					  GFile *file;
					  gboolean result;
					  file = g_file_new_for_path (filename);
					  result = gtk_file_chooser_select_file (chooser, file, NULL);
//#define GTK_FILE_CHOOSER_GET_IFACE(inst)  (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_CHOOSER, GtkFileChooserIface))
					  //result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, NULL);
					  g_object_unref (file);*/
				}
				return 1;
			}
			sh_->builder_->get_widget(p1, tOb);
			if(tOb){
				if(p->size()<3){
					cpy__(buf,tOb->get_label().c_str(),siz);
				}else{
					tOb->set_label(text);
				}
				return 1;
			}
			sh_->builder_->get_widget(p1, sB);
			if(sB){
				if(p->size()<3){
				}else{
					sB->push(text,sB->get_context_id(text));
					return 1;
				}
			}
			sh_->builder_->get_widget(p1, n);
			if(n){
				if(p->size()<3){
					cpy__(buf,n->get_current_page()+1,siz);
				}else{
					n->set_current_page(s2i__(text,1)-1);
				}
				return 1;
			}
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="勾选"){
		if(siz==-1)return 1;
		if(p->size()>2){
			bool b=d_(sh_,bool_,(*p)[p->size()-1].c_str());
			for(size_t i=1;i<p->size()-1;i++){
				sh_->builder_->get_widget((*p)[i], tOb);
				if(tOb){
					tOb->set_active(b);
					continue;
				}
				sh_->builder_->get_widget((*p)[i], ttb);
				if(ttb){
					ttb->set_active(b);
					continue;
				}
				sh_->builder_->get_widget((*p)[i], cmi);
				if(cmi){
					cmi->set_active(b);
					continue;
				}
				d_(sh_,err_show_wufa_,2,p,i);
				return 1;
			}
		}else{
			sh_->builder_->get_widget(p1, tOb);
			if(tOb){
				cpy__(buf,tOb->get_active(),siz);
				return 1;
			}
			sh_->builder_->get_widget(p1, ttb);
			if(ttb){
				cpy__(buf,ttb->get_active(),siz);
				return 1;
			}
			sh_->builder_->get_widget(p1, cmi);
			if(cmi){
				cpy__(buf,cmi->get_active(),siz);
				return 1;
			}
			d_(sh_,err_show_wufa_,2,p,1);
		}
		return 1;
	}
	if(p0=="提示文字"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget(p1, w);
		if(w){
			if(p->size()<3){
				cpy__(buf,w->get_tooltip_markup().c_str(),siz);
			}else{
				w->set_tooltip_markup((*p)[2]);
			}
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="焦点"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget(p1, w);
		if(w){
			w->grab_focus();
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="侦听"){
		if(siz==-1)return 1;
		if(p->size()>2){
			if(p1=="点击"){
				Glib::ustring code;
				size_t size=p->size();
				if(size>=4)
					code=(*p)[--size];
				for(size_t i=2;i<size;i++){
					if((*p)[i].length()==0)
						continue;
					Glib::SignalProxy0< void >* sp0=NULL;
					Glib::SignalProxy1< bool, GdkEventButton* >* sp1=NULL;
					Glib::ustring dong;
					bI=NULL;
					w=NULL;
					for(;;){
						sh_->builder_->get_widget((*p)[i], b);
						if(b){
							bI=b;
							w=b;
							dong=b->get_label();
							sp0=&b->signal_clicked();
							break;
						}

						sh_->builder_->get_widget((*p)[i], tb);
						if(tb){
							bI=tb;
							w=tb;
							dong=tb->get_label();
							sp0=&tb->signal_clicked();
							break;
						}

						sh_->builder_->get_widget((*p)[i], mi);
						if(mi){
							bI=mi;
							w=mi;
							sp1=&mi->signal_button_press_event();
							break;
						}

						sh_->builder_->get_widget((*p)[i], w);
						if(w){
							sp1=&w->signal_button_press_event();
							break;
						}

						d_(sh_,err_show_wufa_,3,p,i,0);
						return 1;
					}

					if(w){
						const char*arg4;
						if(dong.empty()){
							dong=(*p)[i];
							arg4=NULL;
						}else
							arg4=(*p)[i].c_str();
						control___* c;
						const char*zhao;
						const char*arg3;
						//不buf会乱指
						Glib::ustring buf3;
						if(w==mi){
							zhao="菜单";
							buf3=mi->get_label();
						}else{
							zhao=bI!=NULL?"按钮":p1.c_str();
							buf3=w->get_tooltip_text();
						}
						arg3=buf3.c_str();
						if(!arg4)
							c=new control___(zhao,dong.c_str(),sh_,d_,code.c_str(),arg3);
						else
							c=new control___(zhao,dong.c_str(),sh_,d_,code.c_str(),arg3,arg4);
						if(sp0)
							sp0->connect(sigc::mem_fun(*c, &control___::on__));
						else if(sp1)
							sp1->connect(sigc::mem_fun(*c, &control___::on1__));
						w->set_data("ctl",c);
						if(p->size()==4)
							break;
					}
				}
				return 1;
			}
			d_(sh_,err_show_wufa_,2,p,1);
			return 1;
		}
		d_(sh_,err_show_buzu_,p);
		return 1;
	}
	if(p0=="点击"){
		if(siz==-1)return 1;
		for(size_t i=1;i<p->size();i++){
			w=NULL;
			for(;;){
				sh_->builder_->get_widget((*p)[i], b);
				if(b){
					w=b;
					break;
				}
				sh_->builder_->get_widget((*p)[i], tb);
				if(tb){
					w=tb;
					break;
				}
				sh_->builder_->get_widget((*p)[i], mi);
				if(mi){
					w=mi;
					break;
				}
				sh_->builder_->get_widget((*p)[i], w);
				if(w){
					break;
				}
				d_(sh_,err_show_wufa_,3,p,i,0);
				return 1;
			}
			control___* c=(control___*)w->get_data("ctl");
			if(!c){
				d_(sh_,err_show_wufa_,3,p,i,0);
				return 1;
			}
			c->on__();
		}
		return 1;
	}
	if(p0=="可见"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget(p1, w);
		if(w){
			if(p->size()>2){
				bool b=d_(sh_,bool_,(*p)[p->size()-1].c_str());
				for(size_t i=1;i<p->size()-1;i++){
					sh_->builder_->get_widget((*p)[i], w);
					if(w)
						w->set_visible(b);
					else
						d_(sh_,err_show_wufa_,2,p,i);
				}
			}else
				cpy__(buf,w->get_visible(),siz);
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="可见状态"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget(p1, e);
		if(e){
			bool b;
			if(p->size()>2)
				b=d_(sh_,bool_,(*p)[2].c_str());
			else
				b=!e->get_visibility();
			e->set_visibility(b);
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="敏感"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget(p1, w);
		if(w){
			if(p->size()>2){
				bool b=d_(sh_,bool_,(*p)[p->size()-1].c_str());
				for(size_t i=1;i<p->size()-1;i++){
					sh_->builder_->get_widget((*p)[i], w);
					if(w)
						w->set_sensitive(b);
					else
						d_(sh_,err_show_wufa_,2,p,i);
				}
			}else
				cpy__(buf,w->get_sensitive(),siz);
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="区域信息"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget(p1, w);
		if(w){
			Gtk::Allocation a=w->get_allocation();
			sprintf(buf,"%d,%d,%d,%d,",a.get_x(),a.get_y(),a.get_width(),a.get_height());
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="鼠标"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget(p1, w);
		if(w){
			gint  x,y;
			/*Glib::RefPtr<Gdk::Window> w2=w->get_window();
			w2->get_pointer(x,y,);*/
			w->get_pointer(x,y);
			sprintf(buf,"%d,%d,",x,y);
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="数目"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget(p1, n);
		if(n){
			sprintf(buf,"%d",n->get_n_pages());
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="遍历"){
		if(siz==-1)return 1;
		const Glib::ustring& code=(*p)[p->size()-1];
		bool exe=true;
		char s1[16];
		const char*argv[]={s1};
		int err;
		for(size_t i=1;i<p->size()-1&&exe;i++){
			sh_->builder_->get_widget((*p)[i], n);
			if(n){
				for(int pn=0;pn<n->get_n_pages();pn++){
					w=n->get_nth_page(pn);
					sprintf(s1,"%d",pn+1);
					d_(sh_,call4_1_,code.c_str(),shangji,NULL,NULL,NULL,1,argv,0,ce,&err);
					if(err){
						if(err==jieshiqi_go_+keyword_break_)
							break;
						if(err==jieshiqi_go_+keyword_continue_)
							continue;
						if(err==jieshiqi_go_+keyword_exit_){
							exe=false;
							break;
						}
						d_(sh_,call4_2_,err);
						return 1;
					}
				}
				continue;
			}
			d_(sh_,err_show_wufa_,2,p,i);
		}
		return 1;
	}
	return 0;
}
Exemple #30
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();
}