void tcontainer_::set_active(const bool active)
{
	// Not all our children might have the proper state so let them run
	// unconditionally.
	grid_.set_active(active);

	if(active == get_active()) {
		return;
	}

	set_dirty();

	set_self_active(active);
}
Esempio n. 2
0
// ---------------------------------------------------------------------------
// 
// -----------
void bToolMove::set_modifiers(int k){	
	bStdToolGeom::set_modifiers(k);
	if(!get_active()){
		return;
	}
	if(is_modifiers(optionKey)){
		set_curs(_ccopy);
		_copy=true;
	}
	else{
		set_curs();
		_copy=false;
	}
	_srep=!is_modifiers(shiftKey);
}
Esempio n. 3
0
void trepeating_button::signal_handler_left_button_up(
		const event::tevent event, bool& handled)
{
	DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";

	if(repeat_timer_) {
		remove_timer(repeat_timer_);
		repeat_timer_ = 0;
	}

	if(get_active()) {
		set_state(FOCUSSED);
	}
	handled = true;
}
Esempio n. 4
0
void
chooser::on_changed ()
{
  if (inhibit_callback_) return;

  const std::string& udi = get_active ()->get_value (cols_->udi);
  type_id type = get_active ()->get_value (cols_->type);

  if (cache_ && udi == cache_->get_value (cols_->udi)) return;

  /**/ if (ACTION  == type) dropdown::on_changed ();
  else if (CUSTOM  == type) on_custom (udi);
  else if (SYSTEM  == type) on_system (udi);
  else if (MESSAGE == type)
    {
      inhibit_callback_ = true;
      if (cache_) set_active (cache_);
      inhibit_callback_ = false;
    }
  else
    {
      // FIXME log unsupported type error
    }
}
    std::string ValueComboBox::getActive()
    {
        Gtk::TreeModel::iterator iter = get_active();
        if(iter)
        {
            Gtk::TreeModel::Row row = *iter;
            if(row)
            {
                
                Glib::ustring aValue = row[_columns._name];
                return aValue;
            }
        }

        return "";
    }
Esempio n. 6
0
            void plot_history::new_page() {
                if (!_replaying) {
                    auto previous_plot = get_active();
                    if (previous_plot != nullptr) {
                        pGEDevDesc ge_dev_desc = Rf_desc2GEDesc(_device_desc);
                        util::protected_sexp snapshot(ge_dev_desc->savedSnapshot);
                        if (previous_plot->has_pending_render()) {
                            previous_plot->set_snapshot(snapshot);
                            previous_plot->render(false);
                        }
                    }

                    // Create a plot object for this new page
                    append(std::make_unique<plot>(_device_desc));
                }
            }
// ---------------------------------------------------------------------------
// 
// -----------
void bToolJustification::set_modifiers(int k){	
	bStdToolPres::set_modifiers(k);
	if(!get_active()){
		return;
	}
	if(is_modifiers(cmdKey)){
		set_curs(_cright);
		_umode=kJustificationUserModeRight;
		set_use_track(false);
		set_use_drag(false);
	}
	else if(is_modifiers(optionKey)){
		set_curs(_cmiddle);
		_umode=kJustificationUserModeCenter;
		set_use_track(false);
		set_use_drag(false);
	}
	else if(is_modifiers(controlKey)){
		set_curs(_cleft);
		_umode=kJustificationUserModeLeft;
		set_use_track(false);
		set_use_drag(false);
	}
	else if(is_modifiers(shiftKey)){
		if(_fspc){
			set_curs(_cspace);
			_umode=kJustificationUserModeSpace;
			set_use_track(true);
			set_use_drag(true);
		}
		else{
			set_curs();
			_umode=kJustificationUserModeStd;
			set_use_track(true);
			set_use_drag(true);
		}
	}
	else{
		set_curs();
		_umode=kJustificationUserModeStd;
		if(get_on_drag()){
			set_use_track(true);
			set_use_drag(true);
		}
	}
}
Esempio n. 8
0
      /**
       *  Checks to see if we have signatures of the active authorites of
       *  the accounts specified in authority or the keys specified. 
       */
      bool check_authority( const authority* au, uint32_t depth = 0 )
      {
         if( au == nullptr ) return false;
         const authority& auth = *au;

         uint32_t total_weight = 0;
         for( const auto& k : auth.key_auths )
            if( signed_by( k.first ) )
            {
               total_weight += k.second;
               if( total_weight >= auth.weight_threshold )
                  return true;
            }

         for( const auto& k : auth.address_auths )
            if( signed_by( k.first ) )
            {
               total_weight += k.second;
               if( total_weight >= auth.weight_threshold )
                  return true;
            }

         for( const auto& a : auth.account_auths )
         {
            if( approved_by.find(a.first) == approved_by.end() )
            {
               if( depth == max_recursion )
                  return false;
               if( check_authority( get_active( a.first ), depth+1 ) )
               {
                  approved_by.insert( a.first );
                  total_weight += a.second;
                  if( total_weight >= auth.weight_threshold )
                     return true;
               }
            }
            else
            {
               total_weight += a.second;
               if( total_weight >= auth.weight_threshold )
                  return true;
            }
         }
         return total_weight >= auth.weight_threshold;
      }
Esempio n. 9
0
static void
g_socket_service_get_property (GObject    *object,
                               guint       prop_id,
                               GValue     *value,
                               GParamSpec *pspec)
{
  GSocketService *service = G_SOCKET_SERVICE (object);

  switch (prop_id)
    {
    case PROP_ACTIVE:
      g_value_set_boolean (value, get_active (service));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
static void
set_enable_screen_part_ui (GtkWidget *widget, ZoomOptionsPrivate *priv)
{
    gboolean screen_part;

    /* If the "screen part" radio is not checked, then the "follow mouse" radio
     * is checked (== lens mode). Set mouse tracking back to the default.
     */
    screen_part = get_active (priv->screen_part_radio);
    if (!screen_part)
      {
        g_settings_set_string (priv->settings,
                               "mouse-tracking", "proportional");
      }

    set_sensitive (priv->centered_radio, screen_part);
    set_sensitive (priv->push_radio, screen_part);
    set_sensitive (priv->proportional_radio, screen_part);
    set_sensitive (priv->extend_beyond_checkbox, screen_part);
}
Esempio n. 11
0
void control::on_toggled()
{
	if(m_data.get())
	{
		// If the value hasn't changed, we're done ...
		const bool new_value = get_active();
		if(new_value != m_data->value())
		{
			// Turn this into an undo/redo -able event ...
			if(m_data->state_recorder)
				m_data->state_recorder->start_recording(k3d::create_state_change_set(K3D_CHANGE_SET_CONTEXT), K3D_CHANGE_SET_CONTEXT);

			// Update everything with the new value ...
			m_data->set_value(new_value);

			// Turn this into an undo/redo -able event ...
			if(m_data->state_recorder)
				m_data->state_recorder->commit_change_set(m_data->state_recorder->stop_recording(K3D_CHANGE_SET_CONTEXT), new_value ? m_data->change_message + " \"On\"" : m_data->change_message + " \"Off\"", K3D_CHANGE_SET_CONTEXT);
		}
	}

	base::on_toggled();
}
Esempio n. 12
0
void control::on_list_changed()
{
	Gtk::TreeIter active = get_active();
	return_if_fail(active != m_implementation->m_list_model->children().end());

	Gtk::TreeRow row = *active;
	const k3d::string_t value = row[m_implementation->m_columns.value];

	return_if_fail(m_implementation->m_model.get());

	if(value == m_implementation->m_model->value())
		return;

	if(m_implementation->m_state_recorder)
		m_implementation->m_state_recorder->start_recording(k3d::create_state_change_set(K3D_CHANGE_SET_CONTEXT), K3D_CHANGE_SET_CONTEXT);

	m_implementation->m_model->set_value(value);

	if(m_implementation->m_state_recorder)
	{
		const k3d::string_t change_message = k3d::string_cast(boost::format(_("Change %1% to %2%")) % m_implementation->m_model->label().raw() % value);
		m_implementation->m_state_recorder->commit_change_set(m_implementation->m_state_recorder->stop_recording(K3D_CHANGE_SET_CONTEXT), change_message, K3D_CHANGE_SET_CONTEXT);
	}
}
Esempio n. 13
0
bool sign_state::check_authority( const authority& auth, uint32_t depth )
{
   uint32_t total_weight = 0;
   for( const auto& k : auth.key_auths )
   {
      if( signed_by( k.first ) )
      {
         total_weight += k.second;
         if( total_weight >= auth.weight_threshold )
            return true;
      }
   }

   for( const auto& a : auth.account_auths )
   {
      if( approved_by.find(a.first) == approved_by.end() )
      {
         if( depth == max_recursion )
            continue;
         if( check_authority( get_active( a.first ), depth+1 ) )
         {
            approved_by.insert( a.first );
            total_weight += a.second;
            if( total_weight >= auth.weight_threshold )
               return true;
         }
      }
      else
      {
         total_weight += a.second;
         if( total_weight >= auth.weight_threshold )
            return true;
      }
   }
   return total_weight >= auth.weight_threshold;
}
Esempio n. 14
0
// ---------------------------------------------------------------------------
// 
// -----------
void bToolRedraw::update(bool global){
	if(get_active()){
		if(!global){
			clearTempPathContext(false);
		}
		if(get_use_locs()){
			if(_ec>1){
i2dvertex		bck;
				get_cur(&bck);
				if(bck.h!=LONG_MIN){
					get_locs()->add(&bck);
					get_locs()->add(&_vxb);
					draw_poly(true,false);
					get_locs()->rmv(get_locs()->count());
					get_locs()->rmv(get_locs()->count());
				}
			}
		}
		bToolGeomWithJoin::update(global);
		if(!global){
			validTempPathContext();
		}
	}
}
Esempio n. 15
0
void repeating_button::set_active(const bool active)
{
	if(get_active() != active) {
		set_state(active ? ENABLED : DISABLED);
	}
}
Esempio n. 16
0
File: serial.c Progetto: reyesr/lcrt
static struct lcrtc_user *lcrt_serial_create(struct lcrt_qconnect *lqconnect)
{
    lcrt_protocol_t protocol = lqconnect->nproto;
    struct lcrt_window *lwindow = lqconnect->parent;
    struct lcrt_serial_if *lserial = (struct lcrt_serial_if *)lqconnect->private_data;
    struct lcrt_serial_map serial_buad_rate[] = {LCRT_SERIAL_BAUD_RATE_TABLE};
    struct lcrt_serial_map serial_databit[] = {LCRT_SERIAL_DATA_BITS_TABLE};
    struct lcrtc_user *user;
    char password[PASSWORD_LEN];
    char s_port[USERNAME_LEN];
    char name[HOSTNAME_LEN];
    char hostname[HOSTNAME_LEN];
#define get_text(widget) (gtk_combo_box_get_active_text(GTK_COMBO_BOX(lserial->widget)))
#define get_active(widget) (gtk_combo_box_get_active(GTK_COMBO_BOX(lserial->widget)))
    snprintf(s_port, USERNAME_LEN, "%s", get_text(port));
    debug_where();
    if (access(s_port, F_OK|R_OK|W_OK) == -1) {
        switch (errno) {
        case ENOENT:
            debug_print("device %s is not exist.\n", s_port);
            break;
        case EPERM:
            debug_print("you have no permition to open %s.\n", s_port);
            break;
        case EIO:
            debug_print("device %s is not ready.\n", s_port);
            break;
        default:
            debug_print("unknown error,error code is %d\n", errno);
            break;
        }
        return NULL;
    }
    int baud_rate,s_baud_rate;
    baud_rate = get_active(baud_rate);
    s_baud_rate = serial_buad_rate[baud_rate].data;
    debug_where();

    int databit, s_databit;
    databit = atoi(get_text(data_bits));
    databit = get_active(data_bits);
    s_databit = serial_databit[databit].data;
    debug_where();
    
    int s_parity;
    s_parity = get_active(parity);
    debug_where();

    int s_stopbits;
    s_stopbits = get_active(stop_bits);
    debug_where();

    int s_software, s_hardware;
    s_software = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lserial->software));
    s_hardware = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lserial->hardware));
    /* port baud_rate databit parity stopbit software_control hardware_control*/
    snprintf(password, PASSWORD_LEN, "%s %d %d %d %d %d %d", 
            s_port,
            s_baud_rate,
            s_databit,
            s_parity,
            s_stopbits,
            s_software,
            s_hardware);
    strcpy(hostname, basename(s_port));
    if (lqconnect->flag != LCRT_QCONNECT_SESSION_OPTION) {
        if ((user = lcrtc_user_create()) == NULL) {
            /* 
             * FIXME: There is no more memory, how can 
             * we handle this exception ?
             */
            return NULL;
        }

        lcrt_user_find_unused_label(lwindow, hostname, name);

        lcrtc_user_set_data(
           user,
           name,
           hostname,
           protocol,
           NULL,
           password,
           gtk_entry_get_text(GTK_ENTRY(lqconnect->q_et_default_command)),
           0,
           TRUE,
           lqconnect->folder,
           0
        );
        lcrtc_user_ref(user);
        lcrt_user_add(&lwindow->u_config, user);
        lcrt_window_set_current_user(lwindow, user);
        if (lqconnect->flag == LCRT_QCONNECT_IN_TAB) {
            lcrt_create_terminal(lwindow->w_notebook);
        }
    } else {
        if ((user = lcrt_user_find_by_name(&lwindow->u_config, lqconnect->uname)) != NULL) {
            lcrtc_user_set_data(
               user,
               lqconnect->uname,
               hostname,
               protocol,
               NULL,
               password,
               gtk_entry_get_text(GTK_ENTRY(lqconnect->q_et_default_command)),
               0,
               TRUE,
               NULL,
               -1
            );
        }
    }
    lcrtc_user_dump(user, __func__);
    return user;
#undef get_text
#undef get_active
}
Esempio n. 17
0
void ttrack::set_active(const bool active)
{ 
	if (get_active() != active) {
		set_state(active ? ENABLED : DISABLED); 
	}
};
Esempio n. 18
0
	/** Inherited from tcontrol. */
	void set_active(const bool active)
		{ if(get_active() != active) set_state(active ? ENABLED : DISABLED); }
bool MineToggleButton::on_button_release_event(GdkEventButton *event)
{
    if (get_active())
    {
        return true;
    }
    int i = row, j = column;
    Size sz = game->get_size();
    Tile *tile = game->get_board()[sz.width*i+j];
    if (event->button == 3)
    {
        // RMB click => toggle flag
        tile->set_marked(!tile->is_marked());
        delete get_image();
        auto img = new Gtk::Image(tile->is_marked() ? "res/flag.png" : "res/0.png");
        set_image(*img);
        img->show();
        return true;
    }
    if (event->button == 1 && tile->is_marked())
    {
        // LMB click on flagged tile => ignore
        return true;
    }
    set_active(true);
    delete get_image();
    game->sweep_tile(row, column);
    int val = tile->get_value();
    std::string img_path;
    if (val < 0)
    {
        img_path = "res/mine_e.png";
    }
    else
    {
        std::ostringstream convert;
        convert << val;
        img_path = "res/" + convert.str() + ".png";
    }
    auto img = new Gtk::Image(img_path);
    set_image(*img);
    img->show();
    // update all the rest of tiles
    for (int i = 0; i < sz.height; i++)
    {
        for (int j = 0; j < sz.width; j++)
        {
            int loc = sz.width*i+j;
            if (tiles->at(loc) == this)
            {
                continue;
            }
            Tile *board_tile = game->get_board()[loc];
            if (game->is_over() || (!board_tile->is_marked() &&
                board_tile->is_swept() && !tiles->at(loc)->get_active()))
            {
                if (!game->is_over())
                {
                    tiles->at(loc)->set_active(true);
                }
                delete tiles->at(loc)->get_image();
                val = board_tile->get_value();
                if (val < 0)
                {
                    img_path = "res/mine.png";
                }
                else
                {
                    std::ostringstream convert;
                    convert << val;
                    img_path = "res/" + convert.str() + ".png";
                }
                img = new Gtk::Image(img_path);
                tiles->at(loc)->set_image(*img);
                img->show();
            }
        }
    }
    if (game->is_over())
    {
        std::string msg = game->get_unsafe_tile_count() == 0 ? "You win!" : "You lose.";
        Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK);
        dialog.run();
        game->get_window()->reset(game->get_game_difficulty());
    }
    return true;
}
Esempio n. 20
0
bool tcontrol::disable_click_dismiss() const
{
	return get_visible() == twidget::VISIBLE && get_active();
}
Esempio n. 21
0
bool sign_state::check_authority( string id )
{
   if( approved_by.find(id) != approved_by.end() ) return true;
   return check_authority( get_active(id) );
}
Esempio n. 22
0
/**
 * Replaces the currently active quadrant with a process' buffer.
 * 
 * @param	buffer_num		The window (user process) to make active
 */
Uint8 replace_active( Uint32 buffer_num ) {
	return set_active( buffer_num, get_active() );
}
Esempio n. 23
0
/**
 * Handles processing of interrupts from the PS/2 controller.
 *
 * @param	vec			The number of the interrupt code that triggered this
 *						call.
 */
void _ps2_keyboard_isr( int vec, int code ){
	
	// temp vars
	Uint quad;

	Uint key = __inb( PS2_PORT );

	// Handle extended keys first
	if( await_next ){
		if( key == 0xFE ){
			_ps2_ack_int();
			return;
		}
		else{

			// Check if we are going to perform an active window switch
			if( win_pressed ){
				quad = get_active();

				// Determine offset arrow-keys to change active window
				switch( key ){
					case PS2_KEY_UP_P:
						if( quad > 1 )
							quad -= 2;
						break;
					case PS2_KEY_DOWN_P:
						if( quad < 2 )
							quad += 2;
						break;
					case PS2_KEY_LEFT_P:
						if( quad % 2 == 1 )
							quad -= 1;
						break;
					case PS2_KEY_RIGHT_P:
						if( quad % 2 == 0 )
							quad += 1;
				}
				switch_active( quad );
			}

			// resolve the extended key
			switch( key ){
				case PS2_KEY_LWIN_P:
				case PS2_KEY_RWIN_P:
					win_pressed = 1;
					break;
				case PS2_KEY_CTRL_P:
					ctrl_pressed = 1;
					break;
				case PS2_KEY_CTRL_R:
					ctrl_pressed = 0;
					break;
				case PS2_KEY_ALT_P:
					alt_pressed = 1;
					break;
				case PS2_KEY_ALT_R:
					alt_pressed = 0;
					break;
			}
			await_next = 0;
		}
	}

	// Next, handle special keys
	switch( key ){
		case PS2_KEY_LSHIFT_P:
		case PS2_KEY_RSHIFT_P:
			shift_pressed = 1;
			return;
		case PS2_KEY_LSHIFT_R:
		case PS2_KEY_RSHIFT_R:
			shift_pressed = 0;
			return;
		case PS2_KEY_CAPLCK_P:
			caps_lock = 1;
			return;
		case PS2_KEY_CAPLCK_R:
			caps_lock = 0;
			return;
		case PS2_KEY_CTRL_P:
			ctrl_pressed = 1;
			return;
		case PS2_KEY_ALT_P:
			alt_pressed = 1;
			return;
		case PS2_KEY_ALT_R:
			alt_pressed = 0;
			return;
	}

	// normal ASCII characters
	if( key < 0x80 ){

		// check if function-key
		if( key >= PS2_KEY_F1_P && key <= PS2_KEY_F10_P ){
			replace_active( key - PS2_KEY_F1_P );
		}
		else if( key == PS2_KEY_F11_P || key == PS2_KEY_F12_P ){
			replace_active( key - PS2_KEY_F11_P + 10 );
		}
		else{

			// otherwise give the character to the waiting focused process
			char letter = _ps2_scan_code[ shift_pressed ][ key ];
			if( letter != '\377' && letter != '\033' && letter != '\b'
					&& letter != '\t'){
				_ps2_write_to_active( letter );
			}
		}
	}

	// Just the ASCII characters being released
	else if( key >= 0x80 && key <= 0xD8){
		// key released!
	}
	else{
		
		// If we get this byte then that means we should expect an extended key
		if( key == 0xE0 ){
			await_next = 1;
			__outb( PS2_PORT, 0x0 );
		}
	}
	
	_ps2_ack_int();
}
Esempio n. 24
0
	/** Inherited from twidget.*/
	const twidget* find(const std::string& id,
			const bool must_be_active) const
	{
		return (twidget::find(id, must_be_active)
			&& (!must_be_active || get_active())) ? this : 0;
	}
Esempio n. 25
0
	/** Inherited from twidget. */
	const twidget* find_at(const tpoint& coordinate,
			const bool must_be_active) const
	{
		return (twidget::find_at(coordinate, must_be_active)
			&& (!must_be_active || get_active())) ? this : 0;
	}
Esempio n. 26
0
void
chooser::create_device (const std::set<scanner::info>& devices,
                        const std::string& udi)
{
  std::set<scanner::info>::const_iterator it = devices.begin ();
  while (devices.end () != it && udi != it->udi ()) {
    ++it;
  }
  if (devices.end () != it) {

    Glib::RefPtr< Gdk::Window > window = get_window ();

    if (window)
      {
        window->set_cursor (Gdk::Cursor (Gdk::WATCH));
        Gdk::flush ();
      }

    scanner::ptr ptr;
    std::string  why;
    try
      {
        // FIXME This is a bit clunky but scanner creation may be time
        //       consuming and cannot be put in a separate thread if
        //       the scanner object is run via process separation.
        //       The child process would exit at thread end.

        while (Gtk::Main::events_pending ())
          Gtk::Main::iteration ();

        ptr = scanner::create (*it);
      }
    catch (const std::exception& e)
      {
        why = e.what ();
      }
    catch (...)
      {
        // FIXME set a why we failed to create a device
      }

    if (window)
      {
        window->set_cursor ();
      }

    if (ptr)
      {
        cache_ = get_active ();
        set_tooltip_text (it->udi ());
        signal_device_changed_.emit (ptr);
      }
    else
      {
        const std::string& name = get_active ()->get_value (cols_->name);
        const std::string& udi  = get_active ()->get_value (cols_->udi);

        inhibit_callback_ = true;
        if (cache_) set_active (cache_);
        inhibit_callback_ = false;

        BOOST_THROW_EXCEPTION
          (std::runtime_error
           ((format (SEC_("Cannot access %1%\n(%2%)\n%3%"))
             % name
             % udi
             % _(why)
             ).str ()));
      }
  }
}
Esempio n. 27
0
void
chooser::on_run ()
{
  set_active (0);
  cache_ = get_active ();
}
Esempio n. 28
0
void tscrollbar_::set_active(const bool active)
{
	if(get_active() != active) {
		set_state(active ? ENABLED : DISABLED);
	}
}
void VOMS_server_list::activate_handler(){
    VOMS_menu_item *m_item = dynamic_cast<VOMS_menu_item*>(get_active());
    if ( m_item ) {
        client_engine->renew(*m_item);
    }
}
Esempio n. 30
0
void tstate_default::set_active(const bool active)
{
	if(get_active() != active) {
		state_ = active ? ENABLED : DISABLED;
	}
}