예제 #1
0
/**
 * Create a vbox containing widgets allowing to change aspects of
 * toolbar buttons.
 *
 * \return A newly created vbox.
 */
GtkWidget *tab_display_toolbar ( void )
{
    GtkWidget * vbox_pref, * paddingbox, * radio, * radiogroup;
    GtkWidget *vbox;
    GtkWidget *button;

    vbox_pref = new_vbox_with_title_and_icon ( _("Toolbars"), "toolbar.png" );

    paddingbox = new_paddingbox_with_title ( vbox_pref, FALSE,
					     _("Display toolbar buttons as") );

    radiogroup = radio = gtk_radio_button_new_with_label ( NULL, _("Text") );
    g_object_set_data ( G_OBJECT(radio), "display", GINT_TO_POINTER(GSB_BUTTON_TEXT) );
    gtk_box_pack_start ( GTK_BOX(paddingbox), radio, FALSE, FALSE, 0 );
    if ( etat.display_toolbar == GSB_BUTTON_TEXT )
	gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (radio), TRUE );
    g_signal_connect ( G_OBJECT(radio), "toggled",
		       G_CALLBACK(change_toolbar_display_mode), NULL );

    radio = gtk_radio_button_new_with_label_from_widget ( GTK_RADIO_BUTTON(radiogroup),
							  _("Icons") );
    g_object_set_data ( G_OBJECT(radio), "display", GINT_TO_POINTER(GSB_BUTTON_ICON) );
    gtk_box_pack_start ( GTK_BOX(paddingbox), radio, FALSE, FALSE, 0 );
    if ( etat.display_toolbar == GSB_BUTTON_ICON )
	gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (radio), TRUE );
    g_signal_connect ( G_OBJECT(radio), "toggled",
		       G_CALLBACK(change_toolbar_display_mode), NULL );

    radio = gtk_radio_button_new_with_label_from_widget ( GTK_RADIO_BUTTON(radiogroup),
							  _("Both") );
    g_object_set_data ( G_OBJECT(radio), "display", GINT_TO_POINTER(GSB_BUTTON_BOTH) );
    gtk_box_pack_start ( GTK_BOX(paddingbox), radio, FALSE, FALSE, 0 );
    if ( etat.display_toolbar == GSB_BUTTON_BOTH )
	gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (radio), TRUE );
    g_signal_connect ( G_OBJECT(radio), "toggled",
		       G_CALLBACK(change_toolbar_display_mode), NULL );

    gtk_widget_show_all ( vbox_pref );

    if ( !gsb_data_account_get_accounts_amount () )
	gtk_widget_set_sensitive ( vbox_pref, FALSE );

    gtk_box_pack_start ( GTK_BOX ( vbox_pref ),
			 gsb_automem_checkbutton_new ( _("Display headings bar"),
						       &(etat.show_headings_bar),
						       G_CALLBACK (preferences_switch_headings_bar), NULL ),
			 FALSE, FALSE, 0 );

    vbox = new_vbox_with_title_and_icon ( _("Navigation pane"), "organization.png" );
    gtk_box_pack_start ( GTK_BOX ( vbox_pref ), vbox, TRUE, TRUE, 0 );

    button = gsb_automem_checkbutton_new (_("Add mouse scrolling support on the navigation pane"),
                        &conf.active_scrolling_left_pane,
                        G_CALLBACK ( preferences_active_mouse_scrolling_left_pane ),
                        NULL);
    gtk_box_pack_start ( GTK_BOX ( vbox ), button, FALSE, FALSE, 5 );

    return ( vbox_pref );

}
예제 #2
0
파일: tip.c 프로젝트: wazari972/Grisbi
/**
 * Display a tip.
 *
 * \param force  Forcefully display the tip even if show_tip option
 *		 has been disabled.
 */
void display_tip ( gboolean force )
{
    GtkWidget * checkbox;
    GtkWidget * dialog = NULL;
    GtkWidget *btn_back, *btn_forward, *btn_close;
    gchar *tmpstr;

    if ( !force && !conf.show_tip )
        return;

    conf.last_tip = CLAMP ( conf.last_tip+1, 0, sizeof(tips)/sizeof(gpointer)-1);

    dialog = dialogue_special_no_run ( GTK_MESSAGE_INFO, GTK_BUTTONS_NONE,
                        make_hint ( _("Did you know that..."),
                        /* We use the Grisbi-tips catalog */
                        g_dgettext(NULL, tips[conf.last_tip]) ) );
    gtk_window_set_modal ( GTK_WINDOW ( dialog ), FALSE );

    checkbox = gsb_automem_checkbutton_new ( _("Display tips at next start"),
                        &(conf.show_tip), NULL, NULL );
    gtk_box_pack_start ( GTK_BOX ( GTK_DIALOG(dialog) -> vbox ), checkbox, FALSE, FALSE, 6 );
    gtk_widget_show ( checkbox );

    btn_back =    gtk_dialog_add_button (GTK_DIALOG(dialog), GTK_STOCK_GO_BACK, 1);
    btn_forward = gtk_dialog_add_button (GTK_DIALOG(dialog), GTK_STOCK_GO_FORWARD, 2);
    btn_close =   gtk_dialog_add_button (GTK_DIALOG(dialog), GTK_STOCK_CLOSE, 3);

    /* gtk_widget_set_size_request ( dialog, 450, -1 ); */
    /* We iterate as user can select several tips. */
    while ( TRUE )
    {
    if ( conf.last_tip == sizeof(tips)/sizeof(gpointer)-1)
        gtk_widget_set_sensitive (btn_forward, FALSE);
    if ( conf.last_tip == 0)
        gtk_widget_set_sensitive (btn_back, FALSE);

    switch ( gtk_dialog_run ( GTK_DIALOG(dialog) ) )
    {
        case 1:
        if ( conf.last_tip > 0 )
            conf.last_tip--;
        gtk_widget_set_sensitive (btn_forward, TRUE);
        tmpstr = g_strconcat ( make_pango_attribut (
                        "size=\"larger\" weight=\"bold\"", _("Did you know that...") ),
                        "\n\n",
                        g_dgettext (NULL, tips[conf.last_tip] ),
                        NULL );

        gtk_label_set_markup ( GTK_LABEL ( GTK_MESSAGE_DIALOG(dialog) -> label ),
                        tmpstr );
        g_free ( tmpstr );
        break;

        case 2:
        if ( conf.last_tip < sizeof(tips)/sizeof(gpointer)-1)
            conf.last_tip++;
        tmpstr = g_strconcat ( make_pango_attribut (
                        "size=\"larger\" weight=\"bold\"", _("Did you know that...") ),
                        "\n\n",
                        g_dgettext (NULL, tips[conf.last_tip] ),
                        NULL );

        gtk_label_set_markup ( GTK_LABEL ( GTK_MESSAGE_DIALOG(dialog) -> label ),
                        tmpstr );
        g_free ( tmpstr );
        gtk_widget_set_sensitive (btn_back, TRUE);
        break;

        default:
        gtk_widget_destroy ( dialog );
        return;
    }
    }
}
예제 #3
0
/**
 * create the page 3 of the first assistant
 * we create here the title of the file, name of the file and adress
 *
 * \param assistant the GtkWidget assistant
 *
 * \return a GtkWidget containing the page
 * */
static GtkWidget *gsb_assistant_file_page_2 ( GtkWidget *assistant )
{
    GtkWidget *page;
    GtkWidget *vbox;
    GtkWidget *label;
    GtkWidget *entry;
    GtkWidget *scrolled_window;
    GtkWidget *paddingbox;
    GtkWidget *textview;
    GtkWidget *button;
    GtkWidget *table;
    GtkWidget *filename_entry;

    page = gtk_hbox_new (FALSE, 15);
    gtk_container_set_border_width ( GTK_CONTAINER (page),
                                     10 );

    vbox = new_vbox_with_title_and_icon ( _("General configuration"),
                                          "payees.png" );
    gtk_box_pack_start ( GTK_BOX (page),
                         vbox,
                         TRUE, TRUE, 0 );

    /* table 2x3 for layout */
    table = gtk_table_new ( 2, 3, FALSE );
    gtk_table_set_row_spacings ( GTK_TABLE ( table ), 6 );
    gtk_table_set_col_spacings ( GTK_TABLE ( table ), 6 );

    /* Account file title */
    paddingbox = new_paddingbox_with_title ( vbox, FALSE, _("Titles and filenames") );
    gtk_box_pack_start ( GTK_BOX ( paddingbox ), table, FALSE, FALSE, 0);

    /* label account name */
    label = gtk_label_new ( _("Accounts file title: ") );
    gtk_misc_set_alignment (GTK_MISC (label), 0, 1);
    gtk_label_set_justify ( GTK_LABEL (label), GTK_JUSTIFY_LEFT );
    gtk_table_attach ( GTK_TABLE ( table ), label, 0, 1, 0, 1,
                       GTK_SHRINK | GTK_FILL, 0, 0, 0 );

    /* need to declare filename_entry first for the next callback,
     * if no filename, set the title.gsb as default name */
    if (!nom_fichier_comptes)
        nom_fichier_comptes = g_strconcat ( my_get_gsb_file_default_dir (),
                                            G_DIR_SEPARATOR_S, titre_fichier, ".gsb", NULL );
    filename_entry = gsb_automem_entry_new (&nom_fichier_comptes,
                                            NULL, NULL);

    entry = gsb_automem_entry_new (&titre_fichier,
                                   ((GCallback)gsb_assistant_file_change_title), filename_entry);
    g_object_set_data ( G_OBJECT (entry),
                        "last_title", my_strdup (titre_fichier));
    gtk_table_attach ( GTK_TABLE ( table ), entry, 1, 3, 0, 1,
                       GTK_EXPAND | GTK_FILL, 0, 0, 0 );

    /* filename */
    label = gtk_label_new ( _("Filename: ") );
    gtk_misc_set_alignment (GTK_MISC (label), 0, 1);
    gtk_label_set_justify ( GTK_LABEL (label), GTK_JUSTIFY_LEFT );
    gtk_table_attach ( GTK_TABLE ( table ), label, 0, 1, 1, 2,
                       GTK_SHRINK | GTK_FILL, 0, 0, 0 );

    gtk_table_attach ( GTK_TABLE ( table ), filename_entry, 1, 2, 1, 2,
                       GTK_EXPAND | GTK_FILL, 0, 0, 0 );

    button = gtk_button_new_with_label ("...");
    gtk_button_set_relief ( GTK_BUTTON (button), GTK_RELIEF_NONE );
    g_signal_connect ( G_OBJECT (button), "clicked",
                       G_CALLBACK (gsb_assistant_file_choose_filename), filename_entry );

    gtk_table_attach ( GTK_TABLE ( table ), button, 2, 3, 1, 2,
                       GTK_SHRINK | GTK_FILL, 0, 0, 0 );

    /* will we crypt the file ? */
    if ( gsb_plugin_find ( "openssl" ) )
    {
        button = gsb_automem_checkbutton_new ( _("Encrypt Grisbi file"),
                                               &(etat.crypt_file), G_CALLBACK (gsb_gui_encryption_toggled), NULL);
        gtk_box_pack_start ( GTK_BOX ( paddingbox ), button,
                             FALSE, FALSE, 0 );

        if ( etat.crypt_file )
            run.new_crypted_file = TRUE;
    }
    else
    {
        run.new_crypted_file = FALSE;
    }

    /* date format */
    paddingbox = gsb_config_date_format_chosen ( vbox, GTK_ORIENTATION_HORIZONTAL );

    /* decimal and thousands separator */
    paddingbox = gsb_config_number_format_chosen ( vbox, GTK_ORIENTATION_HORIZONTAL );

    /* Address */
    paddingbox = new_paddingbox_with_title ( vbox, FALSE, _("Your address") );

    /* Common address */
    scrolled_window = gtk_scrolled_window_new ( NULL, NULL );
    gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW ( scrolled_window ),
                                     GTK_POLICY_AUTOMATIC,
                                     GTK_POLICY_AUTOMATIC );
    gtk_box_pack_start ( GTK_BOX ( paddingbox ), scrolled_window,
                         FALSE, FALSE, 0);
    gtk_scrolled_window_set_shadow_type ( GTK_SCROLLED_WINDOW(scrolled_window),
                                          GTK_SHADOW_IN );
    textview = gsb_automem_textview_new ( &adresse_commune, NULL, NULL );
    gtk_container_add ( GTK_CONTAINER ( scrolled_window ),
                        textview );

    gtk_widget_show_all (page);
    return page;
}
예제 #4
0
 /**
 * create the config widget for the reconcile
 * to modify/delete a reconcile
 *
 * \param
 *
 * \return a GtkWidget containing the config widget
 */
GtkWidget *gsb_reconcile_config_create ( void )
{
    GtkWidget *scrolled_window;
    GtkWidget *vbox_pref;
    GtkWidget *paddinggrid;
    GtkTreeViewColumn *column;
    GtkCellRenderer *cell;
    GtkTreeStore *reconcile_model;
    GtkTreeSelection *reconcile_selection;
    GtkWidget *label;
    gint i;
    gfloat alignment[] = {
	COLUMN_LEFT, COLUMN_CENTER, COLUMN_CENTER,
	COLUMN_RIGHT, COLUMN_RIGHT
    };
    gchar *titles[] = {
	_("Account"), _("Init date"), _("Final date"),
	_("Init balance"), _("Final balance")
    };
    GtkWidget *table_selection;
    GtkWidget *button;
    gint width_entry = 80;
	GrisbiWinEtat *w_etat;

	w_etat = (GrisbiWinEtat *) grisbi_win_get_w_etat ();
    vbox_pref = new_vbox_with_title_and_icon ( _("Reconciliation"),
					       "gsb-reconciliation-32.png" );

    gsb_automem_radiobutton3_new_with_title ( vbox_pref,
                        _("Select the end date of reconciliation: "),
                        _("Start Date + one month"),
                        _("Today's date"),
                        NULL,
                        &w_etat->reconcile_end_date,
                        G_CALLBACK ( gsb_reconcile_config_end_date_changed ),
                        NULL,
                        GTK_ORIENTATION_HORIZONTAL );

    paddinggrid = utils_prefs_paddinggrid_new_with_title (vbox_pref, _("List of reconciliations"));
	gtk_widget_set_vexpand (paddinggrid, TRUE);

    /* set the list */
    scrolled_window = utils_prefs_scrolled_window_new ( NULL, GTK_SHADOW_IN, SW_COEFF_UTIL_PG, 200);
    gtk_grid_attach (GTK_GRID (paddinggrid), scrolled_window, 0, 0, 3, 3);

    /* need to create first the table to set it in the arg of the changed signal of selection */
    table_selection = gtk_grid_new ();
    gtk_grid_set_row_spacing (GTK_GRID (table_selection), 6);
    gtk_grid_set_column_spacing (GTK_GRID (table_selection), 6);

    /* create the model */
    reconcile_model = gtk_tree_store_new ( NUM_RECONCILIATION_COLUMNS,
					   G_TYPE_STRING,    /* Name account or reconciliation */
					   G_TYPE_STRING,    /* init date  */
					   G_TYPE_STRING,    /* final date  */
					   G_TYPE_STRING,    /* init balance  */
					   G_TYPE_STRING,    /* final balance  */
					   G_TYPE_INT,       /* Account number */
					   G_TYPE_INT,       /* Bold or regular text */
					   G_TYPE_INT,		 /* reconciliation number */
					   GDK_TYPE_RGBA);

	reconcile_treeview = gtk_tree_view_new_with_model ( GTK_TREE_MODEL (reconcile_model) );
	gtk_widget_set_name (reconcile_treeview, "tree_view");
    g_object_unref (G_OBJECT(reconcile_model));
    gtk_tree_selection_set_mode ( gtk_tree_view_get_selection (GTK_TREE_VIEW (reconcile_treeview)),
				  GTK_SELECTION_SINGLE );
    gtk_container_add ( GTK_CONTAINER (scrolled_window), reconcile_treeview );

    reconcile_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (reconcile_treeview));
    g_signal_connect (reconcile_selection,
                      "changed",
                      G_CALLBACK (gsb_reconcile_config_select),
                      table_selection);

    /* Name */
    for (i=RECONCILIATION_NAME_COLUMN ; i<RECONCILIATION_ACCOUNT_COLUMN ; i++)
    {
	cell = gtk_cell_renderer_text_new ();
	g_object_set ( G_OBJECT (cell),
		       "xalign", alignment[i],
		       NULL );
	column = gtk_tree_view_column_new ();
	gtk_tree_view_column_set_sizing ( column,
					  GTK_TREE_VIEW_COLUMN_AUTOSIZE );
	gtk_tree_view_column_set_alignment ( column,
					     alignment[i] );
	gtk_tree_view_column_pack_end ( column, cell, TRUE );
	gtk_tree_view_column_set_title ( column, titles[i] );
	gtk_tree_view_column_set_attributes (column, cell,
					     "text", i,
					     "weight", RECONCILIATION_WEIGHT_COLUMN,
						 "cell-background-rgba", RECONCILIATION_BACKGROUND_COLOR,
					     NULL);
	gtk_tree_view_column_set_expand ( column, TRUE );
	gtk_tree_view_column_set_resizable ( column,
					     TRUE );
	gtk_tree_view_append_column ( GTK_TREE_VIEW(reconcile_treeview), column);
    }

    /* Various remaining settings */
    gsb_reconcile_config_fill();

    /* Set the reconcile_sort */
    button = gsb_automem_checkbutton_new (_("Sort by descending date the reconciliations"),
                                          &w_etat->reconcile_sort,
                                          G_CALLBACK (gsb_reconcile_config_sort_reconcile),
                                          NULL);
    gtk_widget_set_margin_top (button, MARGIN_TOP);
    gtk_grid_attach (GTK_GRID (paddinggrid), button, 0, 3, 1, 1);

	button = gtk_button_new_with_label (_("Collapse row"));
	gtk_widget_set_sensitive (button, FALSE);
	g_signal_connect (G_OBJECT (button),
					  "clicked",
					  G_CALLBACK (gsb_reconcile_button_collapse_row_clicked),
					  reconcile_selection);
	gtk_grid_attach (GTK_GRID (paddinggrid), button, 1, 3, 1, 1);

	/* set signal here because data is button */
    g_signal_connect (reconcile_treeview,
                      "row-expanded",
                      G_CALLBACK (gsb_reconcile_treeview_row_expanded),
                      button);

    g_signal_connect (reconcile_treeview,
                      "row-collapsed",
                      G_CALLBACK (gsb_reconcile_treeview_row_collapsed),
                      button);

    /* set the modifying part under the list */
    paddinggrid = utils_prefs_paddinggrid_new_with_title (vbox_pref,_("Selected reconcile") );

    /* for that we make a table 2x3 but with the names 4x3,
     * the table has been set before to accept as arg on the changed selection */
    gtk_grid_attach (GTK_GRID (paddinggrid), table_selection, 0, 0, 1, 1);

    /* set the name */
	label = gtk_label_new ( _("Reconciliation reference: ") );
	utils_labels_set_alignment ( GTK_LABEL (label), 0, 0.5);
	gtk_label_set_justify ( GTK_LABEL (label), GTK_JUSTIFY_LEFT );
	gtk_grid_attach (GTK_GRID (table_selection), label, 0, 0, 1, 1);

	reconcile_name_entry = gsb_autofunc_entry_new ( NULL,
			G_CALLBACK (gsb_reconcile_config_update_line), reconcile_treeview,
			G_CALLBACK (gsb_data_reconcile_set_name), 0 );
    gtk_widget_set_size_request ( reconcile_name_entry, width_entry, -1 );
	gtk_grid_attach (GTK_GRID (table_selection), reconcile_name_entry, 1, 0, 1, 1);

	/* set the initial date */
	label = gtk_label_new ( _("Initial date: ") );
	utils_labels_set_alignment ( GTK_LABEL (label), 0, 0.5);
	gtk_label_set_justify ( GTK_LABEL (label), GTK_JUSTIFY_LEFT );
	gtk_grid_attach (GTK_GRID (table_selection), label, 0, 1, 1, 1);

	reconcile_init_date_entry = gsb_autofunc_date_new ( NULL,
			G_CALLBACK (gsb_reconcile_config_update_line), reconcile_treeview,
			G_CALLBACK (gsb_data_reconcile_set_init_date), 0 );
    gtk_widget_set_size_request ( reconcile_init_date_entry, width_entry, -1 );
	gtk_grid_attach (GTK_GRID (table_selection), reconcile_init_date_entry, 1, 1, 1, 1);

    /* set the final date */
	label = gtk_label_new ( _("Final date: ") );
	utils_labels_set_alignment ( GTK_LABEL (label), 0, 0.5);
	gtk_label_set_justify ( GTK_LABEL (label), GTK_JUSTIFY_LEFT );
	gtk_grid_attach (GTK_GRID (table_selection), label, 0, 2, 1, 1);

	reconcile_final_date_entry = gsb_autofunc_date_new ( NULL,
			G_CALLBACK (gsb_reconcile_config_update_line), reconcile_treeview,
			G_CALLBACK (gsb_data_reconcile_set_final_date), 0 );
    gtk_widget_set_size_request ( reconcile_final_date_entry, width_entry, -1 );
	gtk_grid_attach (GTK_GRID (table_selection), reconcile_final_date_entry, 1, 2, 1, 1);

    /* set the delete button */
	delete_reconcile_button = gtk_button_new_with_label (_("Delete the reconcile"));
    gtk_button_set_relief ( GTK_BUTTON (delete_reconcile_button), GTK_RELIEF_NORMAL);
	g_signal_connect ( G_OBJECT (delete_reconcile_button), "clicked",
			G_CALLBACK (gsb_reconcile_config_delete),
			reconcile_treeview );
	gtk_grid_attach (GTK_GRID (table_selection), delete_reconcile_button, 2, 0, 2, 1);

	/* set the initial balance */
	label = gtk_label_new ( _("Initial balance: ") );
	utils_labels_set_alignment ( GTK_LABEL (label), 0, 0.5);
	gtk_label_set_justify ( GTK_LABEL (label), GTK_JUSTIFY_LEFT );
	gtk_grid_attach (GTK_GRID (table_selection), label, 2, 1, 1, 1);

	reconcile_init_balance_entry = gsb_autofunc_real_new ( null_real,
			G_CALLBACK (gsb_reconcile_config_update_line), reconcile_treeview,
			G_CALLBACK (gsb_data_reconcile_set_init_balance), 0 );
    gtk_widget_set_size_request ( reconcile_init_balance_entry, width_entry, -1 );
	gtk_grid_attach (GTK_GRID (table_selection), reconcile_init_balance_entry, 3, 1, 1, 1);

    /* set the final balance */
	label = gtk_label_new ( _("Final balance: ") );
	utils_labels_set_alignment ( GTK_LABEL (label), 0, 0.5);
	gtk_label_set_justify ( GTK_LABEL (label), GTK_JUSTIFY_LEFT );
	gtk_grid_attach (GTK_GRID (table_selection), label, 2, 2, 1, 1);

	reconcile_final_balance_entry = gsb_autofunc_real_new ( null_real,
			G_CALLBACK (gsb_reconcile_config_update_line), reconcile_treeview,
			G_CALLBACK (gsb_data_reconcile_set_final_balance), 0 );
    gtk_widget_set_size_request ( reconcile_final_balance_entry, width_entry, -1 );
    gtk_grid_attach (GTK_GRID (table_selection), reconcile_final_balance_entry, 3, 2, 1, 1);

	/* at the beginning, the table is unsensitive */
	gtk_widget_set_sensitive ( table_selection, FALSE );

    /* set the button to find non-associated transactions */
	button = gtk_button_new_with_label (
                        _("Find all marked transactions not associated with a reconciliation"));
	gtk_button_set_relief ( GTK_BUTTON (button), GTK_RELIEF_NORMAL );
    utils_widget_set_padding (button, 0, MARGIN_TOP);
	g_signal_connect ( G_OBJECT (button),
                      "clicked",
                      G_CALLBACK (gsb_reconcile_config_find_alone_transactions),
                      NULL );
    gtk_grid_attach (GTK_GRID (paddinggrid), button, 0, 1, 1, 1);

    gtk_widget_show_all (vbox_pref);
	utils_set_tree_store_background_color (reconcile_treeview, RECONCILIATION_BACKGROUND_COLOR);

	if ( !gsb_data_account_get_accounts_amount () )
    {
	gtk_widget_set_sensitive ( vbox_pref, FALSE );
    }

    return vbox_pref;
}