Esempio n. 1
0
File: layout.c Progetto: m32/mc
void
layout_box (void)
{
    WDialog *layout_dlg;

    old_layout = panels_layout;
    old_output_lines = output_lines;
    layout_dlg = init_layout ();

    if (dlg_run (layout_dlg) == B_ENTER)
    {
        size_t i;

        for (i = 0; i < (size_t) LAYOUT_OPTIONS_COUNT; i++)
            if (check_options[i].widget != NULL)
                *check_options[i].variable = check_options[i].widget->state & C_BOOL;
    }
    else
    {
        /* restore layout */
        panels_layout = old_layout;
        output_lines = old_output_lines;
        update_split (layout_dlg);
    }

    dlg_destroy (layout_dlg);
    layout_change ();
    do_refresh ();
}
Esempio n. 2
0
File: layout.c Progetto: m32/mc
static int
b_left_right_cback (WButton * button, int action)
{
    (void) action;

    if (button == bright_widget)
    {
        if (panels_layout.horizontal_split)
            panels_layout.top_panel_size++;
        else
            panels_layout.left_panel_size++;
    }
    else
    {
        if (panels_layout.horizontal_split)
            panels_layout.top_panel_size--;
        else
            panels_layout.left_panel_size--;
    }

    update_split (WIDGET (button)->owner);
    layout_change ();
    do_refresh ();
    return 0;
}
Esempio n. 3
0
File: layout.c Progetto: artzub/mc
static int
b_left_right_cback (WButton * button, int action)
{
    (void) action;

    if (button == bleft_widget)
        _first_panel_size++;
    else
        _first_panel_size--;

    update_split (button->widget.owner);
    return 0;
}
Esempio n. 4
0
static int layout_callback (struct Dlg_head *h, int Id, int Msg)
{
    switch (Msg){
    case DLG_DRAW:
#ifndef HAVE_X
    	/*When repainting the whole dialog (e.g. with C-l) we have to
    	  update everything*/
   	old_first_panel_size = -1;
    	old_horizontal_split = -1;
    	old_output_lines     = -1;
	attrset (COLOR_NORMAL);
	dlg_erase (h);
	draw_box (h, 1, 2, h->lines - 2, h->cols - 4);
	draw_box (h, 2, 4, 6, first_width);
	draw_box (h, 8, 4, 4, first_width);
	draw_box (h, 2, 5 + first_width, 10, second_width);

	attrset (COLOR_HOT_NORMAL);
	dlg_move (h, 1, (h->cols - strlen(layout_title))/2);
	addstr (layout_title);
	dlg_move (h, 2, 5);
	addstr (title1);
	dlg_move (h, 8, 5);
	addstr (title2);
	dlg_move (h, 2, 6 + first_width);
	addstr (title3);
	update_split ();
	dlg_move (h, 6, 13);
	addch ('=');
	if (console_flag){
	    if (old_output_lines != _output_lines){
		old_output_lines = _output_lines;
		attrset (COLOR_NORMAL);
		dlg_move (h, 9, 16 + first_width);
		addstr (output_lines_label);
		dlg_move (h, 9, 10 + first_width);
		printw ("%02d", _output_lines);
	    }
	}
#endif
	break;

    case DLG_POST_KEY:
	_filetype_mode = check_options [8].widget->state & C_BOOL;
	_permission_mode = check_options [7].widget->state & C_BOOL;
#ifndef HAVE_X
	_equal_split = check_options [6].widget->state & C_BOOL;
#endif
	_menubar_visible = check_options [5].widget->state & C_BOOL;
	_command_prompt = check_options [4].widget->state & C_BOOL;
	_keybar_visible = check_options [2].widget->state & C_BOOL;
	_message_visible = check_options [1].widget->state & C_BOOL;
	_xterm_hintbar = check_options [0].widget->state & C_BOOL;
	if (console_flag){
	    int minimum;
	    if (_output_lines < 0)
		_output_lines = 0;
	    height = LINES - _keybar_visible - _command_prompt -
		     _menubar_visible - _output_lines - _message_visible;
	    if (_message_visible && _xterm_hintbar && xterm_flag) height++;
	    minimum = MINHEIGHT * (1 + _horizontal_split);
	    if (height < minimum){
		_output_lines -= minimum - height;
		height = minimum;
	    }
	} else {
	    height = LINES - _keybar_visible - _command_prompt -
		_menubar_visible - _output_lines - _message_visible;
	    if (_message_visible && _xterm_hintbar && xterm_flag) height++;
	}
	if (_horizontal_split != radio_widget->sel){
	    _horizontal_split = radio_widget->sel;
	    if (_horizontal_split)
		_first_panel_size = height / 2;
	    else
		_first_panel_size = COLS / 2;
	}
	update_split ();
	if (console_flag){
	    if (old_output_lines != _output_lines){
		old_output_lines = _output_lines;
		attrset (COLOR_NORMAL);
		dlg_move (h, 9, 10 + first_width);
		printw ("%02d", _output_lines);
	    }
	}
	break;

    case DLG_END:
	break;
    }
    return 0;
}
Esempio n. 5
0
static cb_ret_t
layout_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
{
    switch (msg) {
    case DLG_DRAW:
    	/*When repainting the whole dialog (e.g. with C-l) we have to
    	  update everything*/
	common_dialog_repaint (h);

   	old_first_panel_size = -1;
    	old_horizontal_split = -1;
    	old_output_lines     = -1;

	attrset (COLOR_HOT_NORMAL);
	update_split ();
	dlg_move (h, 6, 13);
	addch ('=');
	if (console_flag){
	    if (old_output_lines != _output_lines){
		old_output_lines = _output_lines;
		attrset (COLOR_NORMAL);
		dlg_move (h, 9, 16 + first_width);
		addstr (output_lines_label);
		dlg_move (h, 9, 10 + first_width);
		printw ("%02d", _output_lines);
	    }
	}
	return MSG_HANDLED;

    case DLG_POST_KEY:
	_filetype_mode = check_options [8].widget->state & C_BOOL;
	_permission_mode = check_options [7].widget->state & C_BOOL;
	_equal_split = check_options [6].widget->state & C_BOOL;
/* 	_menubar_visible = check_options [5].widget->state & C_BOOL; */
/* 	_command_prompt = check_options [4].widget->state & C_BOOL; */
/* 	_keybar_visible = check_options [2].widget->state & C_BOOL; */
	_message_visible = check_options [1].widget->state & C_BOOL;
/* 	_xterm_title = check_options [0].widget->state & C_BOOL; */
	if (console_flag){
	    int minimum;
	    if (_output_lines < 0)
		_output_lines = 0;
	    height = LINES - _keybar_visible - _command_prompt -
		     _menubar_visible - _output_lines - _message_visible;
	    minimum = MINHEIGHT * (1 + _horizontal_split);
	    if (height < minimum){
		_output_lines -= minimum - height;
		height = minimum;
	    }
	} else {
	    height = LINES - _keybar_visible - _command_prompt -
		_menubar_visible - _output_lines - _message_visible;
	}
	if (_horizontal_split != radio_widget->sel){
	    _horizontal_split = radio_widget->sel;
	    if (_horizontal_split)
		_first_panel_size = height / 2;
	    else
		_first_panel_size = COLS / 2;
	}
	update_split ();
	if (console_flag){
	    if (old_output_lines != _output_lines){
		old_output_lines = _output_lines;
		attrset (COLOR_NORMAL);
		dlg_move (h, 9, 10 + first_width);
		printw ("%02d", _output_lines);
	    }
	}
	return MSG_HANDLED;

    default:
	return default_dlg_callback (h, msg, parm);
    }
}
Esempio n. 6
0
File: layout.c Progetto: m32/mc
static cb_ret_t
layout_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
{
    WDialog *h = DIALOG (w);

    switch (msg)
    {
    case MSG_DRAW:
        /* When repainting the whole dialog (e.g. with C-l) we have to
           update everything */
        dlg_default_repaint (h);

        old_output_lines = -1;

        update_split (h);

        if (old_output_lines != _output_lines)
        {
            old_output_lines = _output_lines;
            tty_setcolor (mc_global.tty.console_flag != '\0' ? COLOR_NORMAL : DISABLED_COLOR);
            widget_move (h, 9, 5);
            tty_print_string (output_lines_label);
            widget_move (h, 9, 5 + 3 + output_lines_label_len);
            tty_printf ("%02d", _output_lines);
        }
        return MSG_HANDLED;

    case MSG_POST_KEY:
        _menubar_visible = check_options[1].widget->state & C_BOOL;
        _command_prompt = (check_options[2].widget->state & C_BOOL) != 0;
        _keybar_visible = check_options[3].widget->state & C_BOOL;
        _message_visible = check_options[4].widget->state & C_BOOL;
        _xterm_title = (check_options[5].widget->state & C_BOOL) != 0;
        _free_space = check_options[6].widget->state & C_BOOL;

        if (mc_global.tty.console_flag != '\0')
        {
            int minimum;

            if (_output_lines < 0)
                _output_lines = 0;
            height = LINES - _keybar_visible - (_command_prompt ? 1 : 0) -
                     _menubar_visible - _output_lines - _message_visible;
            minimum = MINHEIGHT * (1 + panels_layout.horizontal_split);
            if (height < minimum)
            {
                _output_lines -= minimum - height;
                height = minimum;
            }
        }
        else
            height = LINES - _keybar_visible - (_command_prompt ? 1 : 0) -
                     _menubar_visible - _output_lines - _message_visible;

        if (old_output_lines != _output_lines)
        {
            old_output_lines = _output_lines;
            tty_setcolor (mc_global.tty.console_flag != '\0' ? COLOR_NORMAL : DISABLED_COLOR);
            widget_move (h, 9, 5 + 3 + output_lines_label_len);
            tty_printf ("%02d", _output_lines);
        }
        return MSG_HANDLED;

    case MSG_ACTION:
        if (sender == WIDGET (radio_widget))
        {
            if (panels_layout.horizontal_split != radio_widget->sel)
            {
                int eq;

                panels_layout.horizontal_split = radio_widget->sel;

                if (panels_layout.horizontal_split)
                {
                    eq = panels_layout.horizontal_equal;
                    if (eq)
                        panels_layout.top_panel_size = height / 2;
                }
                else
                {
                    eq = panels_layout.vertical_equal;
                    if (eq)
                        panels_layout.left_panel_size = COLS / 2;
                }

                widget_disable (WIDGET (bleft_widget), eq);
                widget_disable (WIDGET (bright_widget), eq);

                update_split (h);
                layout_change ();
                do_refresh ();
            }
            else
                update_split (h);

            return MSG_HANDLED;
        }

        if (sender == WIDGET (check_options[0].widget))
        {
            int eq;

            if (panels_layout.horizontal_split)
            {
                panels_layout.horizontal_equal = check_options[0].widget->state & C_BOOL;
                eq = panels_layout.horizontal_equal;
            }
            else
            {
                panels_layout.vertical_equal = check_options[0].widget->state & C_BOOL;
                eq = panels_layout.vertical_equal;
            }

            widget_disable (WIDGET (bleft_widget), eq);
            widget_disable (WIDGET (bright_widget), eq);

            update_split (h);
            layout_change ();
            do_refresh ();

            return MSG_HANDLED;
        }

        return MSG_NOT_HANDLED;

    default:
        return dlg_default_callback (w, sender, msg, parm, data);
    }
}
Esempio n. 7
0
/**
 * Parse XML transaction node and fill a ImportTransaction with results.
 *
 * \param transaction_node	XML transaction node to parse.
 */
void recuperation_donnees_gnucash_transaction ( xmlNodePtr transaction_node )
{
  struct ImportTransaction * transaction;
  struct ImportAccount * account = NULL;
  struct gnucash_split * split;
  gchar * date_string, *space, *tiers;
  GDate * date;
  xmlNodePtr splits, split_node, date_node;
  GSList * split_list = NULL;
  GsbReal total = { 0 , 0 };

  /* Transaction amount, category, account, etc.. */
  splits = get_child ( transaction_node, "splits" );
  split_node = splits -> children;

  while ( split_node )
    {
      struct ImportAccount * split_account = NULL;
      struct gnucash_category * categ = NULL;
      gint p_r = OPERATION_NORMALE;
      GsbReal amount;

      /**
       * Gnucash transactions are in fact "splits", much like grisbi's
       * splits of transactions.  We need to parse all splits and
       * see whether they are transfers to real accounts or transfers
       * to category accounts.  In that case, we only create one
       * transactions.  The other is discarded as grisbi is not a
       * double part financial engine.
       */
      if ( node_strcmp ( split_node, "split" ) )
	{
	  gchar * account_name = NULL, * categ_name = NULL;

	  split_account = find_imported_account_by_uid ( child_content ( split_node,
									"account" ) );
	  categ = find_imported_categ_by_uid ( child_content ( split_node, "account" ) );
	  amount = gnucash_value ( child_content(split_node, "value") );

	  if ( categ )
	    categ_name = categ -> name;
	  if ( split_account )
	    {
	      /* All of this stuff is here since we are dealing with
		 the account split, not the category one */
	      account_name = split_account -> nom_de_compte;
	      total = gsb_real_add ( total,
				     amount );
	      if ( strcmp(child_content(split_node, "reconciled-state"), "n") )
		p_r = OPERATION_RAPPROCHEE;
	    }

	  split = find_split ( split_list, amount, split_account, categ );
	  if ( split )
	    {
	      update_split ( split, amount, account_name, categ_name );
	    }
	  else
	    {
	      split = new_split ( amount, account_name, categ_name );
	      split_list = g_slist_append ( split_list, split );
	      split -> notes = child_content(split_node, "memo");
	    }
	  if ( p_r != OPERATION_NORMALE )
	      split -> p_r = p_r;
	}

      split_node = split_node -> next;
    }

  if ( ! split_list )
    return;

  /* Transaction date */
  date_node = get_child ( transaction_node, "date-posted" );
  date_string = child_content (date_node, "date");
  space = strchr ( date_string, ' ' );
  if ( space )
    *space = 0;
  date = g_date_new ();
  g_date_set_parse ( date, date_string );
  if ( !g_date_valid ( date ))
    fprintf ( stderr, "grisbi: Can't parse date %s\n", date_string );

  /* Tiers */
  tiers = child_content ( transaction_node, "description" );

  /* Create transaction */
  split = split_list -> data;
  transaction = new_transaction_from_split ( split, tiers, date );
  transaction -> operation_ventilee = 0;
  transaction -> ope_de_ventilation = 0;
  account = find_imported_account_by_name ( split -> account );
  if ( account )
    account -> operations_importees = g_slist_append ( account -> operations_importees, transaction );

  /** Splits of transactions are handled the same way, we process
      them if we find more than one split in transaction node. */
  if ( g_slist_length ( split_list ) > 1 )
    {
      transaction -> operation_ventilee = 1;
      transaction -> montant = total;

      while ( split_list )
	{
	  split = split_list -> data;
	  account = NULL;

	  transaction = new_transaction_from_split ( split, tiers, date );
	  transaction -> ope_de_ventilation = 1;

	  account = find_imported_account_by_name ( split -> account );
	  if ( account )
	    account -> operations_importees = g_slist_append ( account -> operations_importees, transaction );

	  split_list = split_list -> next;
	}
    }
}
Esempio n. 8
0
File: layout.c Progetto: artzub/mc
static cb_ret_t
layout_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
{
    switch (msg)
    {
    case DLG_DRAW:
        /*When repainting the whole dialog (e.g. with C-l) we have to
           update everything */
        common_dialog_repaint (h);

        old_first_panel_size = -1;
        old_horizontal_split = -1;
        old_output_lines = -1;

        update_split (h);

        if (old_output_lines != _output_lines)
        {
            old_output_lines = _output_lines;
            tty_setcolor (mc_global.tty.console_flag ? COLOR_NORMAL : DISABLED_COLOR);
            dlg_move (h, 9, 5);
            tty_print_string (output_lines_label);
            dlg_move (h, 9, 5 + 3 + output_lines_label_len);
            tty_printf ("%02d", _output_lines);
        }
        return MSG_HANDLED;

    case DLG_POST_KEY:
        _menubar_visible = check_options[5].widget->state & C_BOOL;
        _command_prompt = check_options[4].widget->state & C_BOOL;
        _keybar_visible = check_options[3].widget->state & C_BOOL;
        _message_visible = check_options[2].widget->state & C_BOOL;
        _xterm_title = check_options[1].widget->state & C_BOOL;
        _free_space = check_options[0].widget->state & C_BOOL;

        if (mc_global.tty.console_flag)
        {
            int minimum;
            if (_output_lines < 0)
                _output_lines = 0;
            height = LINES - _keybar_visible - _command_prompt -
                _menubar_visible - _output_lines - _message_visible;
            minimum = MINHEIGHT * (1 + _horizontal_split);
            if (height < minimum)
            {
                _output_lines -= minimum - height;
                height = minimum;
            }
        }
        else
            height = LINES - _keybar_visible - _command_prompt -
                _menubar_visible - _output_lines - _message_visible;

        if (old_output_lines != _output_lines)
        {
            old_output_lines = _output_lines;
            tty_setcolor (mc_global.tty.console_flag ? COLOR_NORMAL : DISABLED_COLOR);
            dlg_move (h, 9, 5 + 3 + output_lines_label_len);
            tty_printf ("%02d", _output_lines);
        }
        return MSG_HANDLED;

    case DLG_ACTION:
        if (sender == (Widget *) radio_widget)
        {
            if (_horizontal_split != radio_widget->sel)
            {
                _horizontal_split = radio_widget->sel;
                if (_equal_split)
                {
                    if (_horizontal_split)
                        _first_panel_size = height / 2;
                    else
                        _first_panel_size = COLS / 2;
                }
            }

            update_split (h);

            return MSG_HANDLED;
        }

        if (sender == (Widget *) check_options[6].widget)
        {
            _equal_split = check_options[6].widget->state & C_BOOL;

            widget_disable (bleft_widget->widget, _equal_split);
            send_message ((Widget *) bleft_widget, WIDGET_DRAW, 0);
            widget_disable (bright_widget->widget, _equal_split);
            send_message ((Widget *) bright_widget, WIDGET_DRAW, 0);

            update_split (h);

            return MSG_HANDLED;
        }

        return MSG_NOT_HANDLED;

    default:
        return default_dlg_callback (h, sender, msg, parm, data);
    }
}