コード例 #1
0
ファイル: pack_holder.cpp プロジェクト: NealAbq/heat_wave
  void
  double_slide_holder::
set_values
 (  value_type  val
 ,  value_type  min
 ,  value_type  max
 ,  value_type  ss   // -1 means use existing value
 ,  value_type  ps   // -1 means use existing value
 )
{
    d_assert( ! is_setting( ));

    // We generate our own signals instead of relying on the inner object.
    while_setting_value_wrapper_type wrapper( this, false);
    d_assert( is_setting( ));

    // Remember the old values.
    value_type const  old_val  =  get_value( );
    value_type const  old_min  =  get_min_value( );
    value_type const  old_max  =  get_max_value( );
    value_type const  old_ss   =  get_single_step( );
    value_type const  old_ps   =  get_page_step( );

    // Must do this before the conversions that follow.
    setup_conversions( min, max);

    // Send the values to the inner holder.
    p_inner_holder_->
      set_values
       (  convert_outer_to_inner( val)
        , convert_outer_to_inner( min)
        , convert_outer_to_inner( max)
        , convert_outer_to_inner_distance( ss)
        , convert_outer_to_inner_distance( ps)
       );

    // Find the new values. These may be slightly different due to rounding etc.
    value_type const  new_val  =  get_value( );
    value_type const  new_min  =  get_min_value( );
    value_type const  new_max  =  get_max_value( );
    value_type const  new_ss   =  get_single_step( );
    value_type const  new_ps   =  get_page_step( );

    // Emit the value signals.
    if ( (new_ss != old_ss) || (new_ps != old_ps) ) {
        emit has_changed__steps( new_ss, new_ps);
        wrapper.request_signal( );
    }
    if ( (new_min != old_min) || (new_max != old_max) ) {
        emit has_changed__range( new_min, new_max);
        wrapper.request_signal( );
    }
    if ( new_val != old_val ) {
        emit has_changed( new_val);
        wrapper.request_signal( );
    }

    // The wrapper dtor will signal has_changed( ) if appropriate.
    wrapper.done_with_no_throws( );
}
コード例 #2
0
ファイル: noteoftheday.cpp プロジェクト: haobug/gnote
void NoteOfTheDay::cleanup_old(gnote::NoteManager & manager)
{
  gnote::Note::List kill_list;
  const gnote::Note::List & notes = manager.get_notes();

  Glib::Date date;
  date.set_time_current(); // time set to 00:00:00

  for (gnote::Note::List::const_iterator iter = notes.begin();
       notes.end() != iter; iter++) {
    const std::string & title = (*iter)->get_title();
    const sharp::DateTime & date_time = (*iter)->create_date();

    if (true == Glib::str_has_prefix(title, s_title_prefix)
        && s_template_title != title
        && Glib::Date(
             date_time.day(),
             static_cast<Glib::Date::Month>(date_time.month()),
             date_time.year()) != date
        && !has_changed(*iter)) {
      kill_list.push_back(*iter);
    }
  }

  for (gnote::Note::List::const_iterator iter = kill_list.begin();
       kill_list.end() != iter; iter++) {
    DBG_OUT("NoteOfTheDay: Deleting old unmodified '%s'",
            (*iter)->get_title().c_str());
    manager.delete_note(*iter);
  }
}
コード例 #3
0
ファイル: mtsm.cpp プロジェクト: AhmadTux/DragonFlyBSD
int mtsm::changed(statem *s)
{
  if (s == 0 || !is_html)
    return 0;
  s = new statem(s);
  inherit(s, 0);
  int result = has_changed(MTSM_EOL, s)
	       || has_changed(MTSM_BR, s)
	       || has_changed(MTSM_FI, s)
	       || has_changed(MTSM_IN, s)
	       || has_changed(MTSM_LL, s)
	       || has_changed(MTSM_PO, s)
	       || has_changed(MTSM_RJ, s)
	       || has_changed(MTSM_SP, s)
	       || has_changed(MTSM_TA, s)
	       || has_changed(MTSM_CE, s);
  delete s;
  return result;
}
コード例 #4
0
ファイル: pack_holder.cpp プロジェクト: NealAbq/heat_wave
  /* slot (protected) */
  void
  double_slide_holder::
intercept__has_changed( inner_value_type inner_value)
{
    // These may come from us or from the UI.
    // If they come from us we will signal has_changed( ) later, after signaling
    // all the value changes.
    if ( ! is_setting( ) ) {
        value_type const outer_value = convert_inner_to_outer( inner_value);
        emit has_changed( outer_value);
    }
}
コード例 #5
0
ファイル: edit_typeset.cpp プロジェクト: svn2github/texmacs
void
edit_typeset_rep::typeset_exec_until (path p) {
  //time_t t1= texmacs_time ();
  if (has_changed (THE_TREE + THE_ENVIRONMENT))
    if (p != correct_cursor (et, rp * 0)) {
      if (DEBUG_STD) std_warning << "resynchronizing for path " << p << "\n";
      // apply_changes ();
    }
  if (p == tp && inside_graphics (true) && p != closest_inside (et, p)) {
    //cout << "TeXmacs] Warning: corrected cursor\n";
    tp= closest_inside (et, tp);
    p = tp;
  }

  //cout << "Exec until " << p << LF;
  if (N(cur[p])!=0) return;
  if (N(cur)>=25) // avoids out of memory in weird cases
    typeset_invalidate_env ();
  typeset_prepare ();
  if (enable_fastenv) {
    if (!(rp < p)) {
      failed_error << "Erroneous path " << p << "\n";
      FAILED ("invalid typesetting path");
    }
    tree t= subtree (et, rp);
    path q= path_up (p / rp);
    while (!is_nil (q)) {
      int i= q->item;
      restricted_exec (env, t, i);
      tree w= drd->get_env_child (t, i, tree (ATTR));
      if (w == "") break;
      //cout << "t= " << t << "\n";
      //cout << "i= " << i << "\n";
      //cout << "w= " << w << "\n";
      for (int j=0; j<N(w); j+=2) {
	//cout << w[j] << " := " << env->exec (w[j+1]) << "\n";
	env->write (w[j]->label, env->exec (w[j+1]));
      }
      t= t[i];
      q= q->next;
    }
    if (env->read (PREAMBLE) == "true")
      env->write (MODE, "src");
  }
  else exec_until (ttt, p / rp);
  env->read_env (cur (p));
  //time_t t2= texmacs_time ();
  //if (t2 - t1 >= 10) cout << "typeset_exec_until took " << t2-t1 << "ms\n";
}
コード例 #6
0
ファイル: pack_holder.cpp プロジェクト: NealAbq/heat_wave
  /* ctor */
  double_slide_holder::
double_slide_holder
 (  QObject *   p_parent
  , value_type  outer_init  // = 0.0
  , value_type  outer_lo    // = -1.0
  , value_type  outer_hi    // = +1.0
 )
  : holder_base_type( p_parent)
  , p_inner_holder_ ( 0)
  , outer_lo_       ( 0)
  , inner_to_outer_ ( 0)
  , outer_to_inner_ ( 0)
{
    setup_conversions( outer_lo, outer_hi);

    // Now that conversions are set up, create the inner holder.
    // Should we use the global lo/hi limits, or the calculated limits? We'll use the
    // calculated limits for now.
    p_inner_holder_ =
        new inner_holder_type
             (  this
              , convert_outer_to_inner( outer_init)
              , convert_outer_to_inner( outer_lo)
              , convert_outer_to_inner( outer_hi)
             );
    d_assert( p_inner_holder_);

    // Relay all the signals from the inner holder.
    d_verify( connect(
        p_inner_holder_, SIGNAL( has_changed( )),
        this, SLOT( intercept__has_changed( ))
    ));
    d_verify( connect(
        p_inner_holder_, SIGNAL( has_changed( int)),
        this, SLOT( intercept__has_changed( int))
    ));
    d_verify( connect(
        p_inner_holder_, SIGNAL( has_changed__range( int, int)),
        this, SLOT( intercept__has_changed__range( int, int))
    ));
    d_verify( connect(
        p_inner_holder_, SIGNAL( has_changed__steps( int, int)),
        this, SLOT( intercept__has_changed__steps( int, int))
    ));

    // Should always be true when outside class methods.
    d_assert( is_valid( ));
}
コード例 #7
0
ファイル: main.c プロジェクト: pbleser/mdp
/*
 * Edit the passwords.
 *
 * This function dumps all the plain-text passwords ("results") in a temporary
 * file in your * ~/.mdp/ folder, fires your editor and save the output back
 * to your password file.
 */
void
edit_results()
{
	int i, tmp_fd = -1;
	struct result *result;
	uint32_t sum = 0, size = 0;
	char line[MAX_LINE_SIZE];

	if (atexit(atexit_cleanup) != 0)
		err(1, "get_results atexit");

	signal(SIGINT, sig_cleanup);
	signal(SIGKILL, sig_cleanup);

	/* Create the temporary file for edit mode. */
	snprintf(tmp_path, MAXPATHLEN, "%ls/.mdp/tmp_edit.XXXXXXXX", home);
	tmp_fd = mkstemp(tmp_path);
	if (tmp_fd == -1) {
		err(1, "edit_results mkstemp()");
	}

	/* Iterate over the results and dump them in this file. */
	for (i = 0; i < ARRAY_LENGTH(&results); i++) {
		result = ARRAY_ITEM(&results, i);
		wcstombs(line, result->value, sizeof(line));
		if (write(tmp_fd, line, strlen(line)) == -1)
			err(1, "edit_results write");
	}

	if (close(tmp_fd) != 0) {
		err(1, "edit_results close(tmp_fd)");
	}

	spawn_editor(tmp_path);

	if (has_changed(tmp_path, sum, size)) {
		gpg_encrypt(tmp_path);
	} else {
		fprintf(stderr, "No changes, exiting...\n");
	}
}
コード例 #8
0
ファイル: inputreader.cpp プロジェクト: codejoust/webbot
	int poll_updates(){

		if (has_changed()){
			// read file
			string cmd;
			string args;
			ifstream readerin(filename);

			/*
			// go to end of the file
			readerin.seekg(0, readerin.end);
			
			// unget last line
			readerin.unget();
			readerin.unget();

			while(readerin.peek() != '\n'){
				readerin.unget();
			}
			*/

			// discard created time.
			getline(readerin, args, ',');
			getline(readerin, cmd,  ',');
			getline(readerin, args, '\n');

			//cout << "reading in - cmd: " << cmd  << ", args: " << args << endl;

			readerin.close();
			check_input(cmd, args);
			ofstream readclear(filename, ios::trunc);
			readclear.close();

		}
		
		return 0;
	}
コード例 #9
0
ファイル: int_holder.cpp プロジェクト: NealAbq/heat_wave
  void
  int_range_steps_holder::
set_values
 (  value_type  val
  , value_type  min
  , value_type  max
  , value_type  ss   // = -1
  , value_type  ps   // = -1
 )
{
    d_assert( is_valid( ));

    // Use existing values if negative steps specified.
    if ( ss < 0 ) { ss = get_single_step( ); }
    if ( ps < 0 ) { ps = get_page_step(   ); }

    // Make sure the new values are valid. Min and single-step never change here.
    if ( max < min ) { max = min; }
    if ( val < min ) { val = min; }
    if ( val > max ) { val = max; }
    if ( (0 != ps) && (ps < ss) ) { ps = ss; }

    // Find out what's going to change.
    bool const  is_changed__val  = (value_       != val);
    bool const  is_changed__min  = (min_value_   != min);
    bool const  is_changed__max  = (max_value_   != max);
    bool const  is_changed__ss   = (single_step_ != ss );
    bool const  is_changed__ps   = (page_step_   != ps );

    // We're done if nothing is changing.
    if ( is_changed__val ||
         is_changed__min ||
         is_changed__max ||
         is_changed__ss  ||
         is_changed__ps  )
    {
        if ( is_setting( ) ) {
            d_assert( false);
        } else {
            while_setting_value_wrapper_type wrapper( this);

            // Set the values in this holder.
            if ( is_changed__val ) { value_       = val; }
            if ( is_changed__min ) { min_value_   = min; }
            if ( is_changed__max ) { max_value_   = max; }
            if ( is_changed__ss  ) { single_step_ = ss ; }
            if ( is_changed__ps  ) { page_step_   = ps ; }
            d_assert( is_valid( ));

            // Loop thru all the attached widgets (spinboxes and sliders).
            // We don't have to relay our has_changed.. signals to these ctrls because we
            // keep them in sync here.
            list_type::iterator        iter        = attached_widgets_.begin( );
            list_type::iterator const  iter_limit  = attached_widgets_.end( );
            while ( iter != iter_limit ) {
                QWidget * p_widget = *iter;
                d_assert( p_widget);

                QSpinBox * p_spinb = qobject_cast< QSpinBox * >( p_widget);
                if ( p_spinb ) {
                    move_values_to( p_spinb);
                } else {
                    QAbstractSlider * p_slider = qobject_cast< QAbstractSlider * >( p_widget);
                    d_assert( p_slider);
                    move_values_to( p_slider);
                }
                
                ++ iter;
            }

            // Emit the value signals. The has_changed( ) signal with no args will be emitted last.
            if ( is_changed__ss || is_changed__ps ) {
                emit has_changed__steps( get_single_step( ), get_page_step( ));
            }
            if ( is_changed__min || is_changed__max ) {
                emit has_changed__range( get_min_value( ), get_max_value( ));
            }
            if ( is_changed__val ) {
                emit has_changed( get_value( ));
            }

            // The dtor for this wrapper emits the has_changed( ) signal.
            wrapper.done_with_no_throws( );
        }
    }
    d_assert( is_valid( ));
}
コード例 #10
0
ファイル: preferences.c プロジェクト: Bgods/r-source
void applyGUI(Gui newGUI)
{
    rect r = getrect(RConsole);
    ConsoleData p = (ConsoleData) getdata(RConsole);
    int havenewfont = 0;
    struct structGUI curGUI;

    getActive(&curGUI);

    if(!has_changed(&curGUI, newGUI)) return;

    if(newGUI->MDI != curGUI.MDI || newGUI->toolbar != curGUI.toolbar ||
       newGUI->statusbar != curGUI.statusbar)
	askok(G_("The overall console properties cannot be changed\non a running console.\n\nSave the preferences and restart Rgui to apply them.\n"));

    if(strcmp(newGUI->language, curGUI.language)) {
	char *buf = malloc(50);
	askok(G_("The language for menus cannot be changed on a\n running console.\n\nSave the preferences and restart Rgui to apply to menus.\n"));
	snprintf(buf, 50, "LANGUAGE=%s", newGUI->language);
	putenv(buf);
    }


/*  Set a new font? */
    if(strcmp(newGUI->font, curGUI.font) ||
       newGUI->pointsize != curGUI.pointsize ||
       strcmp(newGUI->style, curGUI.style))
    {
	char msg[LF_FACESIZE + 128];
	int sty = Plain;

	if(newGUI->tt_font) strcpy(fontname, "TT "); else strcpy(fontname, "");
	strcat(fontname,  newGUI->font);
	if (!strcmp(newGUI->style, "bold")) sty = Bold;
	if (!strcmp(newGUI->style, "italic")) sty = Italic;
	pointsize = newGUI->pointsize;
	fontsty = sty;

	/* Don't delete font: open pagers may be using it */
	if (strcmp(fontname, "FixedFont"))
	    consolefn = gnewfont(NULL, fontname, fontsty, pointsize, 0.0, 1);
	else consolefn = FixedFont;
	if (!consolefn) {
	    snprintf(msg, LF_FACESIZE + 128,
		     G_("Font %s-%d-%d  not found.\nUsing system fixed font"),
		     fontname, fontsty | FixedWidth, pointsize);
	    R_ShowMessage(msg);
	    consolefn = FixedFont;
	}
	/* if (!ghasfixedwidth(consolefn)) {
	   sprintf(msg,
	   G_("Font %s-%d-%d has variable width.\nUsing system fixed font"),
	   fontname, fontsty, pointsize);
	   R_ShowMessage(msg);
	   consolefn = FixedFont;
	   } */
	p->f = consolefn;
	FH = fontheight(p->f);
	FW = fontwidth(p->f);
	havenewfont = 1;
    }

/* resize console, possibly with new font */
    if (consoler != newGUI->crows || consolec != newGUI->ccols || havenewfont) {
	char buf[20];
	consoler = newGUI->crows;
	consolec = newGUI->ccols;
	r.width = (consolec + 1) * FW;
	r.height = (consoler + 1) * FH;
	resize(RConsole, r);
	snprintf(buf, 20, "%d", ROWS); settext(f_crows, buf);
	snprintf(buf, 20, "%d", COLS); settext(f_ccols, buf);
    }
    if (p->lbuf->dim != newGUI->cbb || p->lbuf->ms != newGUI->cbl)
	xbufgrow(p->lbuf, newGUI->cbb, newGUI->cbl);

/* Set colours and redraw */
    for (int i=0; i<numGuiColors; i++)
    	p->guiColors[i] = guiColors[i] = newGUI->guiColors[i];
    drawconsole(RConsole, r);
    if(haveusedapager &&
       (newGUI->prows != curGUI.prows || newGUI->pcols != curGUI.pcols))
	askok(G_("Changes in pager size will not apply to any open pagers"));
    pagerrow = newGUI->prows;
    pagercol = newGUI->pcols;

    if(newGUI->pagerMultiple != pagerMultiple) {
	if(!haveusedapager ||
	   askokcancel(G_("Do not change pager type if any pager is open\nProceed?"))
	   == YES)
	    pagerMultiple = newGUI->pagerMultiple;
	if(pagerMultiple) {
	    check(rb_mwin); uncheck(rb_swin);
	} else {check(rb_swin); uncheck(rb_mwin);}
    }

    setWidthOnResize = newGUI->setWidthOnResize;
    consolebuffered = newGUI->buffered;

    Rwin_graphicsx = newGUI->grx;
    Rwin_graphicsy = newGUI->gry;
    
    p->cursor_blink = newGUI->cursor_blink;
}
コード例 #11
0
		t_uint32 get_state() {
			t_uint32 state = preferences_state::resettable;
			if (has_changed()) state |= preferences_state::changed;
			return state;
		}