Exemple #1
0
static void set_tab_editor_settings(GuPrefsGui* prefs)
{
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs->autoindentation),
                               TO_BOOL(config_get_value("autoindentation")));
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs->spaces_instof_tabs),
                               TO_BOOL(config_get_value("spaces_instof_tabs")));
  gtk_spin_button_set_value(prefs->tabwidth,
                            atoi(config_get_value("tabwidth")));
  gtk_spin_button_set_value(prefs->autosave_timer,
                            atoi(config_get_value("autosave_timer")));
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs->autosaving),
                               TO_BOOL(config_get_value("autosaving")));
  if (!config_get_value("autosaving"))
    gtk_widget_set_sensitive(GTK_WIDGET(prefs->autosave_timer), FALSE);
}
Exemple #2
0
static void set_tab_miscellaneous_settings(GuPrefsGui* prefs)
{
  GtkTreeModel* combo_lang = 0;
  GtkTreeIter iter;
  const gchar* lang = 0;
  gint count = 0;
  gboolean valid = FALSE;

  combo_lang = gtk_combo_box_get_model(GTK_COMBO_BOX(prefs->combo_languages));
  lang = config_get_value("spell_language");
  valid = gtk_tree_model_get_iter_first(combo_lang, &iter);

  while (valid) {
    const gchar* str_value;
    gtk_tree_model_get(combo_lang, &iter, 0, &str_value, -1);
    if (STR_EQU(lang, str_value)) {
      gtk_combo_box_set_active(GTK_COMBO_BOX(prefs->combo_languages), count);
      break;
    }
    ++count;
    valid = gtk_tree_model_iter_next(combo_lang, &iter);
  }

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs->autoexport),
                               TO_BOOL(config_get_value("autoexport")));

}
Exemple #3
0
static void set_tab_preview_settings(GuPrefsGui* prefs)
{

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs->compile_status),
                               TO_BOOL(config_get_value("compile_status")));

  if (!config_get_value("compile_status"))
    gtk_widget_set_sensitive(GTK_WIDGET(prefs->compile_timer), FALSE);

  gtk_spin_button_set_value(prefs->compile_timer,
                            atoi(config_get_value("compile_timer")));
  /* compile scheme */
  if (STR_EQU(config_get_value("compile_scheme"), "real_time"))
    gtk_combo_box_set_active(prefs->compile_scheme, 1);

  if (STR_EQU(config_get_value("animated_scroll"), "always")) {
    gtk_combo_box_set_active(prefs->combo_animated_scroll, 0);
  } else if (STR_EQU(config_get_value("animated_scroll"), "never")) {
    gtk_combo_box_set_active(prefs->combo_animated_scroll, 2);
  } else {
    gtk_combo_box_set_active(prefs->combo_animated_scroll, 1);
  }

  gtk_spin_button_set_value(prefs->spin_cache_size,
                            atoi(config_get_value("cache_size")));
}
Exemple #4
0
static void set_tab_view_settings(GuPrefsGui* prefs)
{
  gboolean value = FALSE;

  value = TO_BOOL(config_get_value("textwrapping"));
  if (value) {
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs->textwrap_button),
                                 value);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs->wordwrap_button),
                                 TO_BOOL(config_get_value("wordwrapping")));
  } else
    gtk_widget_set_sensitive(GTK_WIDGET(prefs->wordwrap_button), FALSE);

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs->line_numbers),
                               TO_BOOL(config_get_value("line_numbers")));
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs->highlighting),
                               TO_BOOL(config_get_value("highlighting")));

}
Exemple #5
0
static VALUE rwire_amq_client_session_publish_content(VALUE self,
	VALUE r_content,
	VALUE exchange,
	VALUE routing_key,
        VALUE r_mandatory,
        VALUE r_immediate)
{
	char * exch = NULL;
	char * rkey = NULL;

	bool mandatory = TO_BOOL(r_mandatory);
	bool immediate = TO_BOOL(r_immediate);

    	amq_client_session_t * session = NULL;
	amq_content_basic_t  * content = amq_content_basic_new();

	if (!NIL_P(exchange)) {
		exch = StringValuePtr(exchange);
	}

	if (!NIL_P(routing_key)) {
		rkey = StringValuePtr(routing_key);
	}

	Data_Get_Struct(self, amq_client_session_t, session);
	Data_Get_Struct(r_content, amq_content_basic_t, content);

	int rc = 0;
	do {
		rc = amq_client_session_basic_publish(session, content, 0, exch, rkey, mandatory, immediate);
		if (rc) {
			rb_raise(eAMQError, "Failed to publish message");
		}
	} while (false);

	return self;
}
Exemple #6
0
static VALUE rwire_amq_client_session_publish_body(VALUE self,
	VALUE body,
	VALUE exchange,
	VALUE routing_key,
        VALUE r_mandatory,
        VALUE r_immediate,
        VALUE r_reply_to)
{
	char * exch = NULL;
	char * rkey = NULL;
	char * reply_to = NULL;

	bool mandatory = TO_BOOL(r_mandatory);
	bool immediate = TO_BOOL(r_immediate);

    	amq_client_session_t * session = NULL;
	amq_content_basic_t *  content = amq_content_basic_new();

	if (!NIL_P(exchange)) {
		exch = StringValuePtr(exchange);
	}

	if (!NIL_P(routing_key)) {
		rkey = StringValuePtr(routing_key);
	}

	if (!NIL_P(r_reply_to)) {
		reply_to = StringValuePtr(r_reply_to);
	}

	Data_Get_Struct(self, amq_client_session_t, session);

	int rc = 0;
	char * errmsg = NULL;

	do {
		char * blob = new_blob_from_rb_str(body);
		int    size = RSTRING_LEN(body);

		// Set the content body
		rc = amq_content_basic_set_body(content, blob, size, free);
		if (rc) {
			errmsg = "Unable to set content body";
			break;
		}

		// Set the reply_to field if passed in
		if (reply_to) {
			rc = amq_content_basic_set_reply_to(content, reply_to);
			if (rc) {
				errmsg = "Unable to set reply_to field";
				break;
			}

		}

		// Publish
		rc = amq_client_session_basic_publish(session, content, 0, exch, rkey, mandatory, immediate);
		if (rc) {
			errmsg = "Failed to publish message";
			break;
		}

	} while (false);

	if (content) {
		amq_content_basic_unlink(&content);
	}
	if (rc) {
		rb_raise(eAMQError, errmsg);
	}

	//TODO check for a more useful value to return
	return self;
}
Exemple #7
0
void Alarm_system_compute(t_Alarm_system_io *_io_, t_Alarm_system_state *_state_) {
    UINT16 activeEvent = ALARM_SYSTEM_TICK;
    if (!_state_->Alarm_system_OPEN) {
        /*  Open the chart  */
        _state_->Alarm_system_OPEN = TRUE;
        /*  Enter the chart's composition  */
        /*  Enter state InitSystem  */
        _state_->InitSystem_OPEN = TRUE;
    } else {
        /*  Execute an open chart  */
        if (_state_->InitSystem_OPEN) {
            /*  Execute state InitSystem  */
            if (_io_->VehLocked == 1) {
                _state_->InitSystem_OPEN = FALSE;
                _state_->AlarmWillBeArmedAfter20sec_OPEN = TRUE;
                /*  Open the inner composition of state AlarmWillBeArmedAfter20sec  */
                /*  Enter state AlarmWillBeArmedAfter20sec.CounterStart  */
                _state_->AlarmWillBeArmedAfter20sec_CounterStart_OPEN = TRUE;
                /*  Perform entry actions of state AlarmWillBeArmedAfter20sec.CounterStart  */
                _state_->Counter = 1;
            } else {
                if (_io_->VehLocked == 0) {
                    _state_->InitSystem_OPEN = FALSE;
                    _state_->VehicleOpen_OPEN = TRUE; //possible BUG 
                } else {
                    /*  Perform during and on-event actions of state InitSystem  */
                    _io_->AlarmArmed = TO_BOOL(1);
                    _io_->AcousticAlarm = TO_BOOL(0);
                    _io_->OpticalAlarm = TO_BOOL(0);
                }
            }
        } else {
            if (_state_->VehicleOpen_OPEN) {
                /*  Execute state VehicleOpen  */
                if (_io_->VehLocked == 1) {
                    _state_->VehicleOpen_OPEN = FALSE;
                    _state_->AlarmWillBeArmedAfter20sec_OPEN = TRUE;
                    /*  Open the inner composition of state AlarmWillBeArmedAfter20sec  */
                    /*  Enter state AlarmWillBeArmedAfter20sec.CounterStart  */
                    _state_->AlarmWillBeArmedAfter20sec_CounterStart_OPEN = TRUE;
                    /*  Perform entry actions of state AlarmWillBeArmedAfter20sec.CounterStart  */
                    _state_->Counter = 1;
                } else {
                    /*  Perform during and on-event actions of state VehicleOpen  */
                    _io_->AlarmArmed = TO_BOOL(0);
                    _io_->AcousticAlarm = TO_BOOL(0);
                    _io_->OpticalAlarm = TO_BOOL(0);
                }
            } else {
                if (_state_->AlarmWillBeArmedAfter20sec_OPEN) {
                    /*  Execute state AlarmWillBeArmedAfter20sec  */
                    if (_state_->Counter == 0 && _io_->VehLocked == 1) {
                        /*  Close the inner composition of state AlarmWillBeArmedAfter20sec  */
                        if (_state_->AlarmWillBeArmedAfter20sec_CounterStart_OPEN) {
                            _state_->AlarmWillBeArmedAfter20sec_CounterStart_OPEN = FALSE;
                        } else {
                            if (_state_->AlarmWillBeArmedAfter20sec_CounterPlus_OPEN) {
                                _state_->AlarmWillBeArmedAfter20sec_CounterPlus_OPEN = FALSE;
                            } else {
                                if (_state_->AlarmWillBeArmedAfter20sec_CounterEnd_OPEN) {
                                    _state_->AlarmWillBeArmedAfter20sec_CounterEnd_OPEN = FALSE;
                                }
                            }
                        }
                        _state_->AlarmWillBeArmedAfter20sec_OPEN = FALSE;
                        _state_->AlarmArmed_OPEN = TRUE;
                    } else {
                        if (_io_->VehLocked == 0) {
                            /*  Close the inner composition of state AlarmWillBeArmedAfter20sec  */
                            if (_state_->AlarmWillBeArmedAfter20sec_CounterStart_OPEN) {
                                _state_->AlarmWillBeArmedAfter20sec_CounterStart_OPEN = FALSE;
                            } else {
                                if (_state_->AlarmWillBeArmedAfter20sec_CounterPlus_OPEN) {
                                    _state_->AlarmWillBeArmedAfter20sec_CounterPlus_OPEN = FALSE;
                                } else {
                                    if (_state_->AlarmWillBeArmedAfter20sec_CounterEnd_OPEN) {
                                        _state_->AlarmWillBeArmedAfter20sec_CounterEnd_OPEN = FALSE;
                                    }
                                }
                            }
                            _state_->AlarmWillBeArmedAfter20sec_OPEN = FALSE;
			    _state_->VehicleOpen_OPEN = TRUE; //possible BUG
                        } else {
                            /*  Perform during and on-event actions of state AlarmWillBeArmedAfter20sec  */
                            _io_->AlarmArmed = TO_BOOL(0);
                            _io_->AcousticAlarm = TO_BOOL(0);
                            _io_->OpticalAlarm = TO_BOOL(0);
                            if (_state_->AlarmWillBeArmedAfter20sec_CounterStart_OPEN) {
                                /*  Execute state AlarmWillBeArmedAfter20sec.CounterStart  */
                                _state_->AlarmWillBeArmedAfter20sec_CounterStart_OPEN = FALSE;
                                _state_->AlarmWillBeArmedAfter20sec_CounterPlus_OPEN = TRUE;
                                /*  Perform entry actions of state AlarmWillBeArmedAfter20sec.CounterPlus  */
                                _state_->Counter = _state_->Counter + 1;
                            } else {
                                if (_state_->AlarmWillBeArmedAfter20sec_CounterPlus_OPEN) {
                                    /*  Execute state AlarmWillBeArmedAfter20sec.CounterPlus  */
                                    if (_state_->Counter < TIMEOUT1 || _io_->VehLocked == 0) {
                                        _state_->AlarmWillBeArmedAfter20sec_CounterPlus_OPEN = FALSE;
                                        _state_->AlarmWillBeArmedAfter20sec_CounterPlus_OPEN = TRUE;
                                        /*  Perform entry actions of state AlarmWillBeArmedAfter20sec.CounterPlus  */
                                        _state_->Counter = _state_->Counter + 1;
                                    } else {
                                        _state_->AlarmWillBeArmedAfter20sec_CounterPlus_OPEN = FALSE;
                                        _state_->AlarmWillBeArmedAfter20sec_CounterEnd_OPEN = TRUE;
                                        /*  Perform entry actions of state AlarmWillBeArmedAfter20sec.CounterEnd  */
                                        _state_->Counter = 0;
                                    }
                                }
                            }
                        }
                    }
                } else {
                    if (_state_->AlarmOnlyOptical_OPEN) {
                        /*  Execute state AlarmOnlyOptical  */
                        if (_state_->Counter == 0) {
                            /*  Close the inner composition of state AlarmOnlyOptical  */
                            if (_state_->AlarmOnlyOptical_CounterPlus_OPEN) {
                                _state_->AlarmOnlyOptical_CounterPlus_OPEN = FALSE;
                            } else {
                                if (_state_->AlarmOnlyOptical_CounterStart_OPEN) {
                                    _state_->AlarmOnlyOptical_CounterStart_OPEN = FALSE;
                                } else {
                                    if (_state_->AlarmOnlyOptical_CounterEnd_OPEN) {
                                        _state_->AlarmOnlyOptical_CounterEnd_OPEN = FALSE;
                                    }
                                }
                            }
                            _state_->AlarmOnlyOptical_OPEN = FALSE;
                            _state_->AlarmArmed_OPEN = TRUE;
                        } else {
                            if (_io_->VehLocked == 0) {
                                /*  Close the inner composition of state AlarmOnlyOptical  */
                                if (_state_->AlarmOnlyOptical_CounterPlus_OPEN) {
                                    _state_->AlarmOnlyOptical_CounterPlus_OPEN = FALSE;
                                } else {
                                    if (_state_->AlarmOnlyOptical_CounterStart_OPEN) {
                                        _state_->AlarmOnlyOptical_CounterStart_OPEN = FALSE;
                                    } else {
                                        if (_state_->AlarmOnlyOptical_CounterEnd_OPEN) {
                                            _state_->AlarmOnlyOptical_CounterEnd_OPEN = FALSE;
                                        }
                                    }
                                }
                                _state_->AlarmOnlyOptical_OPEN = FALSE;
				_state_->VehicleOpen_OPEN = TRUE; //possible BUG
                            } else {
                                /*  Perform during and on-event actions of state AlarmOnlyOptical  */
                                _io_->AlarmArmed = TO_BOOL(0);
                                _io_->AcousticAlarm = TO_BOOL(0);
                                _io_->OpticalAlarm = TO_BOOL(1);
                                if (_state_->AlarmOnlyOptical_CounterPlus_OPEN) {
                                    /*  Execute state AlarmOnlyOptical.CounterPlus  */
                                    if (_state_->Counter < TIMEOUT3 && _io_->VehLocked == 1) {
                                        _state_->AlarmOnlyOptical_CounterPlus_OPEN = FALSE;
                                        _state_->AlarmOnlyOptical_CounterPlus_OPEN = TRUE;
                                        /*  Perform entry actions of state AlarmOnlyOptical.CounterPlus  */
                                        _state_->Counter = _state_->Counter + 1;
                                    } else {
                                        _state_->AlarmOnlyOptical_CounterPlus_OPEN = FALSE;
                                        _state_->AlarmOnlyOptical_CounterEnd_OPEN = TRUE;
                                        /*  Perform entry actions of state AlarmOnlyOptical.CounterEnd  */
                                        _state_->Counter = 0;
                                    }
                                } else {
                                    if (_state_->AlarmOnlyOptical_CounterStart_OPEN) {
                                        /*  Execute state AlarmOnlyOptical.CounterStart  */
                                        _state_->AlarmOnlyOptical_CounterStart_OPEN = FALSE;
                                        _state_->AlarmOnlyOptical_CounterPlus_OPEN = TRUE;
                                        /*  Perform entry actions of state AlarmOnlyOptical.CounterPlus  */
                                        _state_->Counter = _state_->Counter + 1;
                                    }
                                }
                            }
                        }
                    } else {
                        if (_state_->AlarmAcousticAndOptical_OPEN) {
                            /*  Execute state AlarmAcousticAndOptical  */
                            if (_state_->Counter == 0) {
                                /*  Close the inner composition of state AlarmAcousticAndOptical  */
                                if (_state_->AlarmAcousticAndOptical_CounterStart_OPEN) {
                                    _state_->AlarmAcousticAndOptical_CounterStart_OPEN = FALSE;
                                } else {
                                    if (_state_->AlarmAcousticAndOptical_CounterPlus_OPEN) {
                                        _state_->AlarmAcousticAndOptical_CounterPlus_OPEN = FALSE;
                                    } else {
                                        if (_state_->AlarmAcousticAndOptical_CounterEnd_OPEN) {
                                            _state_->AlarmAcousticAndOptical_CounterEnd_OPEN = FALSE;
                                        }
                                    }
                                }
                                _state_->AlarmAcousticAndOptical_OPEN = FALSE;
                                _state_->AlarmOnlyOptical_OPEN = TRUE;
                                /*  Open the inner composition of state AlarmOnlyOptical  */
                                /*  Enter state AlarmOnlyOptical.CounterStart  */
                                _state_->AlarmOnlyOptical_CounterStart_OPEN = TRUE;
                                /*  Perform entry actions of state AlarmOnlyOptical.CounterStart  */
                                _state_->Counter = 1;
                            } else {
                                if (_io_->VehLocked == 0) {
                                    /*  Close the inner composition of state AlarmAcousticAndOptical  */
                                    if (_state_->AlarmAcousticAndOptical_CounterStart_OPEN) {
                                        _state_->AlarmAcousticAndOptical_CounterStart_OPEN = FALSE;
                                    } else {
                                        if (_state_->AlarmAcousticAndOptical_CounterPlus_OPEN) {
                                            _state_->AlarmAcousticAndOptical_CounterPlus_OPEN = FALSE;
                                        } else {
                                            if (_state_->AlarmAcousticAndOptical_CounterEnd_OPEN) {
                                                _state_->AlarmAcousticAndOptical_CounterEnd_OPEN = FALSE;
                                            }
                                        }
                                    }
                                    _state_->AlarmAcousticAndOptical_OPEN = FALSE;
				    _state_->VehicleOpen_OPEN = TRUE; //BUG does not work
                                } else {
                                    /*  Perform during and on-event actions of state AlarmAcousticAndOptical  */
                                    _io_->AlarmArmed = TO_BOOL(0);
                                    _io_->AcousticAlarm = TO_BOOL(1);
                                    _io_->OpticalAlarm = TO_BOOL(1);
                                    if (_state_->AlarmAcousticAndOptical_CounterStart_OPEN) {
                                        /*  Execute state AlarmAcousticAndOptical.CounterStart  */
                                        _state_->AlarmAcousticAndOptical_CounterStart_OPEN = FALSE;
                                        _state_->AlarmAcousticAndOptical_CounterPlus_OPEN = TRUE;
                                        /*  Perform entry actions of state AlarmAcousticAndOptical.CounterPlus  */
                                        _state_->Counter = _state_->Counter + 1;
                                    } else {
                                        if (_state_->AlarmAcousticAndOptical_CounterPlus_OPEN) {
                                            /*  Execute state AlarmAcousticAndOptical.CounterPlus  */
                                            if (_state_->Counter < TIMEOUT2 && _io_->VehLocked == 1) {
                                                _state_->AlarmAcousticAndOptical_CounterPlus_OPEN = FALSE;
                                                _state_->AlarmAcousticAndOptical_CounterPlus_OPEN = TRUE;
                                                /*  Perform entry actions of state AlarmAcousticAndOptical.CounterPlus  */
                                                _state_->Counter = _state_->Counter + 1;
                                            } else {
                                                _state_->AlarmAcousticAndOptical_CounterPlus_OPEN = FALSE;
                                                _state_->AlarmAcousticAndOptical_CounterEnd_OPEN = TRUE;
                                                /*  Perform entry actions of state AlarmAcousticAndOptical.CounterEnd  */
                                                _state_->Counter = 0;
                                            }
                                        }
                                    }
                                }
                            }
                        } else {
                            if (_state_->AlarmArmed_OPEN) {
                                /*  Execute state AlarmArmed  */
                                if (_io_->AlarmSensor == 1) {
                                    _state_->AlarmArmed_OPEN = FALSE;
				    //BUG  _state_->AlarmAcousticAndOptical_OPEN = TRUE; //BUG does not work
                                    /*  Open the inner composition of state AlarmAcousticAndOptical  */
                                    /*  Enter state AlarmAcousticAndOptical.CounterStart  */
                                    _state_->AlarmAcousticAndOptical_CounterStart_OPEN = TRUE;
                                    /*  Perform entry actions of state AlarmAcousticAndOptical.CounterStart  */
                                    _state_->Counter = 1;
                                } else {
                                    if (_io_->VehLocked == 0) {
                                        _state_->AlarmArmed_OPEN = FALSE;
					_state_->VehicleOpen_OPEN = TRUE; //BUG does not work
                                    } else {
                                        /*  Perform during and on-event actions of state AlarmArmed  */
                                        _io_->AlarmArmed = TO_BOOL(1);
                                        _io_->AcousticAlarm = TO_BOOL(0);
                                        _io_->OpticalAlarm = TO_BOOL(0);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}