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);
}
Exemple #2
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 );
}
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);
    }

}
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 #5
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;
}
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");
}
//------------------------------------------------------------------------------
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;
}
Exemple #8
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 #9
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);
    }
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 #11
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 #12
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 #13
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 #14
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();
}
Exemple #15
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();
}
Exemple #16
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);
	}
}
Exemple #17
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();
}