예제 #1
0
bool CTreeViewSystems::on_button_press_event(GdkEventButton* p_event){
	Gtk::TreeModel::iterator l_iter;
	Glib::RefPtr<Gtk::TreeSelection> l_selection;

	Gtk::TreeView::on_button_press_event(p_event);

	l_selection = this->get_selection();
	l_iter = l_selection->get_selected();
	if((p_event->type == GDK_BUTTON_PRESS) && (p_event->button == 3) ) {
		// Actualizamos el menú dependiendo de la selección
		if(l_iter){
			m_action_remove->set_sensitive(true);
			m_action_edit->set_sensitive(true);
	  		m_action_refresh->set_sensitive(true);
	  		m_action_first->set_sensitive(true);
	  		m_action_up->set_sensitive(true);
	  		m_action_down->set_sensitive(true);
	  		m_action_last->set_sensitive(true);
	  		// Comprobamos si se trata del primero
	  		if(l_iter == this->get_model()->children().begin()){
	  	 		m_action_first->set_sensitive(false);
	  	 		m_action_up->set_sensitive(false);
	  		}
	  		// Comprobamos si se trata del último
	  		l_iter++;
	  		if(l_iter == this->get_model()->children().end()){
	  			l_iter--;
	  	  		m_action_last->set_sensitive(false);
	  	  		m_action_down->set_sensitive(false);
	  		}
		}
		else{
			m_action_remove->set_sensitive(false);
			m_action_edit->set_sensitive(false);
	  		m_action_refresh->set_sensitive(false);
	  		m_action_first->set_sensitive(false);
	  		m_action_up->set_sensitive(false);
	  		m_action_down->set_sensitive(false);
	  		m_action_last->set_sensitive(false);
		}

		m_popup_menu->popup(p_event->button, p_event->time);
		return true;
	}
	else if((p_event->type == GDK_2BUTTON_PRESS) && (p_event->button == 1) ) {
		if(l_iter){
			onActionEdit();
			return true;
		}
	}

	return false;
}
예제 #2
0
void	MainWindowImpl::setSlots(void) {
	connect( actionExit,		SIGNAL( triggered() ),	this, SLOT( onActionExit() ) );
	connect( actionConnections,	SIGNAL( triggered() ),	this, SLOT( onActionConnections() ) );
	connect( actionHosts,		SIGNAL( triggered() ),	this, SLOT( onActionHosts() ) );
	connect( actionVariables,	SIGNAL( triggered() ),	this, SLOT( onActionVariables() ) );
	connect( actionProtocols,	SIGNAL( triggered() ),	this, SLOT( onActionProtocols() ) );
    connect( actionAdd,         SIGNAL( triggered() ),	this, SLOT( onActionAdd() ) );
	connect( actionEdit,		SIGNAL( triggered() ),	this, SLOT( onActionEdit() ) );
    connect( actionDel,         SIGNAL( triggered() ),	this, SLOT( onActionDel() ) );
	connect( actionOpen,		SIGNAL( triggered() ),	this, SLOT( onActionOpen() ) );
	connect( actionSettings,	SIGNAL( triggered() ),	this, SLOT( onActionSettings() ) );
	connect( actionBackupDB,	SIGNAL( triggered() ),	this, SLOT( onActionBackup() ) );
	connect( actionRestoreDB,	SIGNAL( triggered() ),	this, SLOT( onActionRestore() ) );
	connect( actionAbout,		SIGNAL( triggered() ),	this, SLOT( onActionAbout() ) );
	connect( actionAboutQt,		SIGNAL( triggered() ),	this, SLOT( onActionAboutQt() ) );
    connect( tray,              SIGNAL( activated ( QSystemTrayIcon::ActivationReason)), this, SLOT(onTray(QSystemTrayIcon::ActivationReason)));
	connect( actionHideRestore,	SIGNAL( triggered() ),	this, SLOT(onHideRestore()));
}