/** * 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 ); }
/** * create the page 4 of the first assistant * we create here the first currency for the software * * \param assistant the GtkWidget assistant * * \return a GtkWidget containing the page * */ static GtkWidget *gsb_assistant_file_page_3 ( GtkWidget *assistant ) { GtkWidget *page; GtkWidget *vbox; page = gtk_hbox_new (FALSE, 15); gtk_container_set_border_width ( GTK_CONTAINER (page), 10 ); vbox = new_vbox_with_title_and_icon ( _("Select base currency"), "currencies.png" ); gtk_box_pack_start ( GTK_BOX (page), vbox, TRUE, TRUE, 0 ); /* set up the menu */ currency_list_box = gsb_currency_config_create_box_popup (NULL); gtk_box_pack_start ( GTK_BOX (vbox), currency_list_box, TRUE, TRUE, 0 ); /* Select default currency. */ gtk_tree_model_foreach ( GTK_TREE_MODEL(g_object_get_data ( G_OBJECT(currency_list_box), "model" )), (GtkTreeModelForeachFunc) gsb_currency_config_select_default, g_object_get_data ( G_OBJECT(currency_list_box), "treeview" ) ); gtk_widget_show_all (page); return page; }
/** * create the last page of the first assistant * * \param assistant the GtkWidget assistant * \param import TRUE if we come to this assistant for importing some files * so by default, set the radiobutton on import files * * \return a GtkWidget containing the page * */ static GtkWidget *gsb_assistant_file_page_finish ( GtkWidget *assistant, gboolean import ) { GtkWidget *page; GtkWidget *vbox; GtkWidget *label; GtkWidget *button; page = gtk_hbox_new (FALSE, 15); gtk_container_set_border_width ( GTK_CONTAINER (page), 10 ); vbox = new_vbox_with_title_and_icon ( _("Configuration finished !"), "reconciliationlg.png" ); gtk_box_pack_start ( GTK_BOX (page), vbox, TRUE, TRUE, 0 ); /* set up the menu */ label = gtk_label_new (_("Default values are now configured for your account file. " "Next assistant will help you creating a new account.\n\n" "Remember that all of the values can be changed in the 'Preferences' dialog.\n\n" "Select a way to populate your account file and press the 'Close' button.")); gtk_misc_set_alignment ( GTK_MISC (label), 0, 0.5 ); gtk_box_pack_start ( GTK_BOX (vbox), label, FALSE, FALSE, 0 ); button_create_account_next = gtk_radio_button_new_with_label ( NULL, _("Create a new account from scratch")); gtk_box_pack_start ( GTK_BOX (vbox), button_create_account_next, FALSE, FALSE, 0 ); button = gtk_radio_button_new_with_label ( gtk_radio_button_get_group (GTK_RADIO_BUTTON (button_create_account_next)), _("Import data from online bank services or from accounting software")); if (import) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE ); gtk_box_pack_start ( GTK_BOX (vbox), button, FALSE, FALSE, 0 ); gtk_widget_show_all (page); return page; }
/** * create and return the page to be set in the configuration page * this is normally the only function which can be called from outside * * \param * * \return the complete page * */ GtkWidget *gsb_form_config_create_page ( void ) { GtkWidget *vbox_pref; vbox_pref = new_vbox_with_title_and_icon ( _("Transaction form"), "form.png" ); /* add the page into the box */ gsb_form_config_make_configuration_box (vbox_pref); if ( !gsb_data_account_get_accounts_amount () ) { gtk_widget_set_sensitive ( vbox_pref, FALSE ); } return vbox_pref; }
/** * create the page 5 of the first assistant * selection of the list of categories * * \param assistant the GtkWidget assistant * * \return a GtkWidget containing the page * */ static GtkWidget *gsb_assistant_file_page_4 ( GtkWidget *assistant ) { GtkWidget *page; GtkWidget *vbox; GtkWidget *button_list; page = gtk_hbox_new (FALSE, 15); gtk_container_set_border_width ( GTK_CONTAINER (page), 10 ); vbox = new_vbox_with_title_and_icon ( _("Select the list of categories you will use"), "categories.png" ); gtk_box_pack_start ( GTK_BOX (page), vbox, TRUE, TRUE, 0 ); button_list = gsb_category_assistant_create_choice_page (assistant); gtk_box_pack_start ( GTK_BOX (vbox), button_list, TRUE, TRUE, 0 ); gtk_widget_show_all (page); return page; }
/** * Creates the "Financial years" tab. It creates a financial years * list and then a form that allows to edit selected financial year. * * \param * * \returns A newly allocated vbox */ GtkWidget *gsb_fyear_config_create_page ( void ) { GtkWidget *vbox_pref, *label; GtkWidget *scrolled_window, *vbox, *hbox; GtkWidget *paddingbox, *table; GtkWidget *tree_view; GtkTreeModel *tree_model; GtkWidget *entry; GtkWidget *button; vbox_pref = new_vbox_with_title_and_icon ( _("Financial years"), "financial-years.png" ); paddingbox = new_paddingbox_with_title ( vbox_pref, TRUE, _("Known financial years") ); hbox = gtk_hbox_new ( FALSE, 5 ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), hbox, TRUE, TRUE, 0); /* Create financial years list */ scrolled_window = gtk_scrolled_window_new ( NULL, NULL ); gtk_box_pack_start ( GTK_BOX ( hbox ), scrolled_window, TRUE, TRUE, 0); gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW ( scrolled_window ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); tree_view = gsb_fyear_config_create_list (); tree_model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); gtk_container_add ( GTK_CONTAINER ( scrolled_window ), tree_view); g_signal_connect ( gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), "changed", G_CALLBACK (gsb_fyear_config_select), NULL ); /* Do not activate unless an account is opened */ if ( gsb_data_account_get_accounts_amount () ) gsb_fyear_config_fill_list (tree_model); else gtk_widget_set_sensitive ( vbox_pref, FALSE ); /* Order buttons in a vbox */ vbox = gtk_vbox_new ( FALSE, 5 ); gtk_box_pack_start ( GTK_BOX ( hbox ), vbox, FALSE, FALSE, 0 ); /* Add button */ button = gtk_button_new_from_stock (GTK_STOCK_ADD); g_signal_connect_swapped ( G_OBJECT (button), "clicked", G_CALLBACK (gsb_fyear_config_add_fyear), tree_view ); gtk_box_pack_start ( GTK_BOX ( vbox ), button, FALSE, FALSE, 5 ); /* Remove button */ button = gtk_button_new_from_stock (GTK_STOCK_REMOVE); gtk_widget_set_sensitive ( button, FALSE ); g_object_set_data ( G_OBJECT (tree_model), "remove_fyear_button", button ); g_signal_connect_swapped ( G_OBJECT (button), "clicked", G_CALLBACK (gsb_fyear_config_remove_fyear), tree_view ); gtk_box_pack_start ( GTK_BOX ( vbox ), button, FALSE, FALSE, 5 ); /* Associate operations : under the list */ hbox = gtk_hbox_new ( FALSE, 5 ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), hbox, FALSE, FALSE, 0); button = gtk_button_new_with_label ( _("Associate operations without financial years") ); g_signal_connect ( G_OBJECT ( button ), "clicked", G_CALLBACK ( gsb_fyear_config_associate_transactions ), NULL ); gtk_box_pack_start ( GTK_BOX (hbox), button, FALSE, FALSE, 5 ); gtk_widget_show ( button ); /* Financial year details */ paddingbox = new_paddingbox_with_title ( vbox_pref, FALSE, _("Financial year details") ); g_object_set_data ( G_OBJECT (tree_model), "paddingbox_details", paddingbox ); /* create a hbox, the table on the left * and the warning on the right */ hbox = gtk_hbox_new ( FALSE, 0); gtk_box_pack_start ( GTK_BOX (paddingbox), hbox, FALSE, FALSE, 0 ); /* Put stuff in a table */ table = gtk_table_new ( 2, 2, FALSE ); gtk_table_set_row_spacings ( GTK_TABLE ( table ), 6 ); gtk_table_set_col_spacings ( GTK_TABLE ( table ), 6 ); gtk_box_pack_start ( GTK_BOX (hbox), table, FALSE, FALSE, 0 ); /* Financial year name */ label = gtk_label_new ( _("Name: ") ); gtk_misc_set_alignment (GTK_MISC (label), 0, 1); gtk_label_set_justify ( GTK_LABEL(label), GTK_JUSTIFY_RIGHT ); gtk_table_attach ( GTK_TABLE ( table ), label, 0, 1, 0, 1, GTK_SHRINK | GTK_FILL, 0, 0, 0 ); entry = gsb_autofunc_entry_new ( NULL, G_CALLBACK (gsb_fyear_config_modify_fyear), tree_view, G_CALLBACK (gsb_data_fyear_set_name), 0 ); g_object_set_data ( G_OBJECT (tree_model), "fyear_name_entry", entry ); gtk_table_attach ( GTK_TABLE ( table ), entry, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0 ); /* Start */ label = gtk_label_new ( _("Start: ") ); gtk_misc_set_alignment (GTK_MISC (label), 0, 1); gtk_label_set_justify ( GTK_LABEL(label), GTK_JUSTIFY_RIGHT ); gtk_table_attach ( GTK_TABLE ( table ), label, 0, 1, 1, 2, GTK_SHRINK | GTK_FILL, 0, 0, 0 ); entry = gsb_autofunc_date_new ( NULL, G_CALLBACK (gsb_fyear_config_modify_fyear), tree_view, G_CALLBACK (gsb_data_fyear_set_beginning_date), 0 ); g_object_set_data ( G_OBJECT (tree_model), "fyear_begin_date_entry", entry ); gtk_table_attach ( GTK_TABLE ( table ), entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0 ); /* End */ label = gtk_label_new ( _("End: ") ); gtk_misc_set_alignment (GTK_MISC (label), 0, 1); gtk_label_set_justify ( GTK_LABEL(label), GTK_JUSTIFY_RIGHT ); gtk_table_attach ( GTK_TABLE ( table ), label, 0, 1, 2, 3, GTK_SHRINK | GTK_FILL, 0, 0, 0 ); entry = gsb_autofunc_date_new ( NULL, G_CALLBACK (gsb_fyear_config_modify_fyear), tree_view, G_CALLBACK (gsb_data_fyear_set_end_date), 0 ); g_object_set_data ( G_OBJECT (tree_model), "fyear_end_date_entry", entry ); gtk_table_attach ( GTK_TABLE ( table ), entry, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 0 ); /* label showed if the fyear is invalid */ label = gtk_label_new (NULL); g_object_set_data ( G_OBJECT (tree_model), "invalid_label", label ); gtk_box_pack_start ( GTK_BOX (hbox), label, FALSE, FALSE, 0 ); /* Activate in transaction form? */ button = gsb_autofunc_checkbutton_new ( _("Activate financial year in transaction form"), FALSE, NULL, NULL, G_CALLBACK (gsb_data_fyear_set_form_show), 0); g_object_set_data ( G_OBJECT (tree_model), "fyear_show_button", button ); gtk_box_pack_start ( GTK_BOX (paddingbox), button, FALSE, FALSE, 0 ); gtk_widget_set_sensitive (paddingbox, FALSE ); return ( vbox_pref ); }
/** * Creates the "Titles & Addresses" tab. This tab is mainly composed * of text entries and editables. * * \returns A newly allocated vbox */ GtkWidget *onglet_display_addresses ( void ) { GtkWidget *hbox, *vbox_pref, *scrolled_window, *label; GtkWidget *paddingbox; GtkWidget *entry; GtkWidget *radio, *radiogroup; vbox_pref = new_vbox_with_title_and_icon ( _("Addresses & titles"), "addresses.png" ); /* Account file title */ paddingbox = new_paddingbox_with_title ( vbox_pref, FALSE, _("Titles") ); /* It first creates the entry of title */ entry = gsb_automem_entry_new ( &titre_fichier, ( GCallback ) update_homepage_title, NULL ); /* Choice of title type */ hbox = gtk_hbox_new ( FALSE, 6 ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), hbox, FALSE, FALSE, 0); radiogroup = gtk_radio_button_new_with_label ( NULL, _("Accounts file title") ); g_object_set_data ( G_OBJECT ( radiogroup ), "display", GINT_TO_POINTER ( GSB_ACCOUNTS_TITLE ) ); if ( conf.display_grisbi_title == GSB_ACCOUNTS_TITLE ) gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( radiogroup ), TRUE ); g_signal_connect ( G_OBJECT ( radiogroup ), "toggled", G_CALLBACK ( change_grisbi_title_type ), entry ); gtk_box_pack_start ( GTK_BOX( hbox ), radiogroup, FALSE, FALSE, 0 ); radio = gtk_radio_button_new_with_label_from_widget ( GTK_RADIO_BUTTON ( radiogroup ), _("Account owner name") ); g_object_set_data ( G_OBJECT ( radio ), "display", GINT_TO_POINTER ( GSB_ACCOUNT_HOLDER ) ); if ( conf.display_grisbi_title == GSB_ACCOUNT_HOLDER ) gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( radio ), TRUE ); g_signal_connect ( G_OBJECT ( radio ), "toggled", G_CALLBACK ( change_grisbi_title_type ), entry ); gtk_box_pack_start ( GTK_BOX( hbox ), radio, FALSE, FALSE, 0 ); radio = gtk_radio_button_new_with_label_from_widget ( GTK_RADIO_BUTTON ( radiogroup ), _("Filename") ); g_object_set_data ( G_OBJECT ( radio ), "display", GINT_TO_POINTER ( GSB_ACCOUNTS_FILE ) ); if ( conf.display_grisbi_title == GSB_ACCOUNTS_FILE ) gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( radio ), TRUE ); g_signal_connect ( G_OBJECT ( radio ), "toggled", G_CALLBACK ( change_grisbi_title_type ), entry ); gtk_box_pack_start ( GTK_BOX( hbox ), radio, FALSE, FALSE, 0 ); hbox = gtk_hbox_new ( FALSE, 6 ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), hbox, FALSE, FALSE, 0); label = gtk_label_new ( _("Accounts file title: ") ); gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 0); if ( conf.display_grisbi_title == GSB_ACCOUNTS_TITLE ) gtk_widget_set_sensitive ( entry, TRUE); else gtk_widget_set_sensitive ( entry, FALSE); gtk_box_pack_start ( GTK_BOX ( hbox ), entry, TRUE, TRUE, 0); /* Addresses */ paddingbox = new_paddingbox_with_title ( vbox_pref, FALSE, _("Addresses") ); /* Common address */ label = gtk_label_new ( _("Common address: ") ); gtk_misc_set_alignment (GTK_MISC (label), 0, 1); gtk_label_set_justify ( GTK_LABEL(label), GTK_JUSTIFY_RIGHT ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), label, TRUE, TRUE, 0); 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 ); entry = gsb_automem_textview_new ( &adresse_commune, NULL, NULL ); gtk_container_add ( GTK_CONTAINER ( scrolled_window ), entry ); /* Secondary address */ /** \note This is not implemented yet */ label = gtk_label_new ( _("Secondary address: ") ); gtk_misc_set_alignment (GTK_MISC (label), 0, 1); gtk_label_set_justify ( GTK_LABEL(label), GTK_JUSTIFY_RIGHT ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), label, TRUE, TRUE, 0); 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_scrolled_window_set_shadow_type ( GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), scrolled_window, FALSE, FALSE, 0); entry = gsb_automem_textview_new ( &adresse_secondaire, NULL, NULL ); gtk_container_add ( GTK_CONTAINER ( scrolled_window ), entry ); if ( !gsb_data_account_get_accounts_amount () ) gtk_widget_set_sensitive ( vbox_pref, FALSE ); return ( vbox_pref ); }
/** * Creates the "Fonts & logo" tab. This function creates some buttons * that are borrowed from applications like gedit. * * \returns A newly allocated vbox */ GtkWidget * onglet_display_fonts ( void ) { GtkWidget *hbox, *vbox_pref, *label, *paddingbox, *font_button; GtkWidget *check_button, *vbox; GdkPixbuf * pixbuf = NULL; GtkWidget *button; GtkWidget *color_combobox; GtkWidget *color_button; vbox_pref = new_vbox_with_title_and_icon ( _("Fonts & logo"), "fonts.png" ); /* Change Grisbi Logo */ paddingbox = new_paddingbox_with_title ( vbox_pref, FALSE, _("Grisbi logo") ); hbox = gtk_hbox_new ( FALSE, 5 ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), hbox, FALSE, FALSE, 0 ); check_button = gtk_check_button_new_with_label ( _("Display a logo")); gtk_box_pack_start ( GTK_BOX ( hbox ), check_button, FALSE, FALSE, 0 ); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( check_button ), etat.utilise_logo ); hbox = gtk_hbox_new ( FALSE, 5 ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), hbox, FALSE, FALSE, 0 ); /* le logo est grisé ou non suivant qu'on l'utilise ou pas */ gtk_widget_set_sensitive ( hbox, etat.utilise_logo ); g_signal_connect ( G_OBJECT ( check_button ), "toggled", G_CALLBACK ( change_choix_utilise_logo ), hbox ); logo_button = gtk_button_new (); gtk_button_set_relief ( GTK_BUTTON ( logo_button ), GTK_RELIEF_NONE ); pixbuf = gsb_select_icon_get_logo_pixbuf ( ); if (!pixbuf) { preview = gtk_image_new_from_pixbuf ( gsb_select_icon_get_default_logo_pixbuf ( ) ); } else { if ( gdk_pixbuf_get_width(pixbuf) > 64 || gdk_pixbuf_get_height(pixbuf) > 64 ) { GdkPixbuf * tmp; tmp = gdk_pixbuf_new ( GDK_COLORSPACE_RGB, TRUE, 8, gdk_pixbuf_get_width(pixbuf)/2, gdk_pixbuf_get_height(pixbuf)/2 ); gdk_pixbuf_scale ( pixbuf, tmp, 0, 0, gdk_pixbuf_get_width(pixbuf)/2, gdk_pixbuf_get_height(pixbuf)/2, 0, 0, 0.5, 0.5, GDK_INTERP_HYPER ); pixbuf = tmp; } preview = gtk_image_new_from_pixbuf (pixbuf); } gtk_container_add (GTK_CONTAINER(logo_button), preview); g_signal_connect_swapped ( G_OBJECT ( logo_button ), "clicked", G_CALLBACK ( modification_logo_accueil ), NULL ); gtk_box_pack_start ( GTK_BOX ( hbox ), logo_button, FALSE, FALSE, 0 ); label = gtk_label_new ( _("Click on preview to change logo") ); gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 0 ); /* Change fonts */ paddingbox = new_paddingbox_with_title ( vbox_pref, FALSE, _("Fonts") ); hbox = gtk_hbox_new ( FALSE, 10 ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), hbox, FALSE, FALSE, 0 ); check_button = gtk_check_button_new_with_label ( _("Use a custom font for the transactions: ")); gtk_box_pack_start ( GTK_BOX ( hbox ), check_button, FALSE, FALSE, 0 ); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( check_button ), conf.utilise_fonte_listes ); /* on crée la vbox qui contiendra la font button et le raz */ vbox = gtk_vbox_new ( FALSE, 10 ); gtk_box_pack_start ( GTK_BOX ( hbox ), vbox, FALSE, FALSE, 0 ); gtk_widget_set_sensitive ( vbox, conf.utilise_fonte_listes ); g_signal_connect ( G_OBJECT ( check_button ), "toggled", G_CALLBACK ( change_choix_utilise_fonte_liste ), vbox ); /* Create font button */ font_button = utils_font_create_button ( &conf.font_string, G_CALLBACK (update_fonte_listes), NULL); gtk_box_pack_start ( GTK_BOX (vbox), font_button, FALSE, FALSE, 0 ); if ( !gsb_data_account_get_accounts_amount () ) { gtk_widget_set_sensitive ( vbox_pref, FALSE ); } /* change colors */ paddingbox = new_paddingbox_with_title ( vbox_pref, FALSE, _("Colors") ); vbox = gtk_vbox_new ( FALSE, 10 ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), vbox, FALSE, FALSE, 10 ); hbox = gtk_hbox_new ( FALSE, 10 ); gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 10 ); color_combobox = gsb_color_create_color_combobox ( ); gtk_box_pack_start ( GTK_BOX (hbox), color_combobox, FALSE, FALSE, 0); color_button = gtk_color_button_new (); gtk_color_button_set_title ( GTK_COLOR_BUTTON(color_button), _("Choosing color") ); g_signal_connect ( G_OBJECT (color_button), "color-set", G_CALLBACK (preferences_view_color_changed), G_OBJECT (color_combobox)); gtk_box_pack_start ( GTK_BOX (hbox), color_button, FALSE, FALSE, 0); /* connect the color button to the combobox if changed */ g_signal_connect ( G_OBJECT (color_combobox), "changed", G_CALLBACK (preferences_view_color_combobox_changed), G_OBJECT (color_button)); button = gtk_button_new_with_label (_("Back to default")); g_signal_connect ( G_OBJECT (button), "clicked", G_CALLBACK (preferences_view_color_default), G_OBJECT (color_combobox)); gtk_box_pack_start ( GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_combo_box_set_active ( GTK_COMBO_BOX (color_combobox), 0); return vbox_pref; }
/** * create the currency_link page for the config * * \param * * \return a newly created box * */ GtkWidget *gsb_currency_link_config_create_page ( void ) { GtkWidget *vbox_pref, *label, *paddingbox, *hbox; GtkWidget *scrolled_window, *vbox; GtkWidget *button; GtkTreeView *tree_view; GtkTreeModel *tree_model; GtkWidget *entry; GtkWidget *combobox; gint width_entry = 170; vbox_pref = new_vbox_with_title_and_icon ( _("Links between currencies"), "currencies.png" ); paddingbox = new_paddingbox_with_title (vbox_pref, TRUE, _("Known links")); hbox = gtk_hbox_new ( FALSE, 5 ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), hbox, TRUE, TRUE, 0); /* links list */ scrolled_window = gtk_scrolled_window_new ( NULL, NULL ); gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW ( scrolled_window ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); /* Create it. */ tree_view = GTK_TREE_VIEW ( gsb_currency_link_config_create_list () ); tree_model = gtk_tree_view_get_model ( tree_view ); gtk_container_add ( GTK_CONTAINER ( scrolled_window ), GTK_WIDGET(tree_view) ); gtk_box_pack_start ( GTK_BOX ( hbox ), scrolled_window, TRUE, TRUE, 0); g_signal_connect ( gtk_tree_view_get_selection (GTK_TREE_VIEW ( tree_view ) ), "changed", G_CALLBACK ( gsb_currency_link_config_select_currency ), NULL ); /* check the keys on the list */ g_signal_connect ( G_OBJECT ( tree_view ), "key_press_event", G_CALLBACK ( gsb_currency_link_config_key_press ), NULL ); /* if nothing opened, all is unsensitive */ if ( !gsb_data_account_get_accounts_amount () ) gtk_widget_set_sensitive ( vbox_pref, FALSE ); else gsb_currency_link_config_fill_list ( tree_model ); /* Create Add/Remove buttons */ vbox = gtk_vbox_new ( FALSE, 5 ); gtk_box_pack_start ( GTK_BOX ( hbox ), vbox, FALSE, FALSE, 0 ); /* Button "Add" */ button = gtk_button_new_from_stock (GTK_STOCK_ADD); g_signal_connect_swapped ( G_OBJECT ( button ), "clicked", G_CALLBACK ( gsb_currency_link_config_add_link ), tree_view ); gtk_box_pack_start ( GTK_BOX ( vbox ), button, FALSE, FALSE, 5 ); /* Button "Remove" */ button = gtk_button_new_from_stock (GTK_STOCK_REMOVE); g_signal_connect_swapped ( G_OBJECT ( button ), "clicked", G_CALLBACK ( gsb_currency_link_config_remove_link ), tree_view ); gtk_box_pack_start ( GTK_BOX ( vbox ), button, FALSE, FALSE, 5 ); /* Input form for currencies */ paddingbox = new_paddingbox_with_title (vbox_pref, FALSE, _("Link properties")); /* Create hbox line */ hbox = gtk_hbox_new ( FALSE, 5 ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), hbox, TRUE, TRUE, 0 ); gtk_widget_set_sensitive ( hbox, FALSE ); g_object_set_data ( G_OBJECT (tree_model), "hbox_line", hbox ); /* Create first currency link entry */ label = gtk_label_new (_("1 ")); gtk_box_pack_start ( GTK_BOX (hbox), label, FALSE, FALSE, 0 ); combobox = gsb_currency_make_combobox (TRUE); gtk_widget_set_size_request ( combobox, width_entry, -1 ); g_object_set_data ( G_OBJECT (tree_model), "combobox_1", combobox ); g_signal_connect_swapped ( G_OBJECT (combobox), "changed", G_CALLBACK (gsb_currency_link_config_modify_link), tree_view ); gtk_box_pack_start ( GTK_BOX (hbox), combobox, FALSE, FALSE, 0 ); /* create the exchange rate between the 2 currencies */ label = gtk_label_new (_(" = ")); gtk_box_pack_start ( GTK_BOX (hbox), label, FALSE, FALSE, 0 ); entry = gtk_entry_new (); gtk_widget_set_size_request ( entry, width_entry/2, -1 ); g_object_set_data ( G_OBJECT (tree_model), "exchange_entry", entry ); g_signal_connect_swapped ( G_OBJECT (entry), "changed", G_CALLBACK (gsb_currency_link_config_modify_link), tree_view ); gtk_box_pack_start ( GTK_BOX (hbox), entry, FALSE, FALSE, 0 ); /* Create second currency link entry */ combobox = gsb_currency_make_combobox (TRUE); gtk_widget_set_size_request ( combobox, width_entry, -1 ); g_object_set_data ( G_OBJECT (tree_model), "combobox_2", combobox ); g_signal_connect_swapped ( G_OBJECT (combobox), "changed", G_CALLBACK (gsb_currency_link_config_modify_link), tree_view ); gtk_box_pack_start ( GTK_BOX (hbox), combobox, FALSE, FALSE, 0 ); /* create fixed exchange rate */ button = gtk_check_button_new_with_label ( _("Fixed exchange rate") ); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( button ), FALSE ); gtk_widget_set_sensitive ( button, FALSE ); g_object_set_data ( G_OBJECT ( tree_model ), "fixed_button", button ); g_signal_connect ( G_OBJECT ( button ), "toggled", G_CALLBACK ( gsb_currency_link_config_button_fixed_changed ), tree_view ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), button, FALSE, FALSE, 0 ); /* Create warning label */ label = gtk_label_new (NULL); g_object_set_data ( G_OBJECT (tree_model), "warning_label", label ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), label, FALSE, FALSE, 0 ); return ( vbox_pref ); }
/** * 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; }
/** * Creates the "Payment methods" tab. It uses a nice GtkTreeView. * * \param * * \returns A newly allocated vbox */ GtkWidget *gsb_payment_method_config_create ( void ) { GtkWidget *vbox_pref, *hbox, *scrolled_window, *paddingbox; GtkWidget *vbox, *table, *menu, *item, *label; GtkTreeViewColumn *column; GtkCellRenderer *cell; GtkWidget *bouton_ajouter_type; GtkTreeStore *payment_method_model; gint width_entry = 80; /* Now we have a model, create view */ vbox_pref = new_vbox_with_title_and_icon ( _("Payment methods"), "payment.png" ); /* Known payment methods */ paddingbox = new_paddingbox_with_title (vbox_pref, TRUE, _("Known payment methods")); hbox = gtk_hbox_new ( FALSE, 6 ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), hbox, TRUE, TRUE, 0 ); /* Create tree */ 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_scrolled_window_set_shadow_type ( GTK_SCROLLED_WINDOW ( scrolled_window ), GTK_SHADOW_IN); gtk_box_pack_start ( GTK_BOX ( hbox ), scrolled_window, TRUE, TRUE, 0 ); /* Create tree view */ payment_method_model = gtk_tree_store_new (NUM_PAYMENT_METHODS_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_INT ); payment_method_treeview = gtk_tree_view_new_with_model ( GTK_TREE_MODEL (payment_method_model) ); g_object_unref (G_OBJECT(payment_method_model)); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (payment_method_treeview), TRUE); g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (payment_method_treeview)), "changed", G_CALLBACK (gsb_payment_method_config_select), payment_method_treeview); /* Account */ cell = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new ( ); gtk_tree_view_column_pack_end ( column, cell, TRUE ); gtk_tree_view_column_set_title ( column, _("Account") ); gtk_tree_view_column_set_attributes (column, cell, "text", PAYMENT_METHODS_NAME_COLUMN, NULL); gtk_tree_view_append_column ( GTK_TREE_VIEW(payment_method_treeview), column); /* Defaults */ cell = gtk_cell_renderer_toggle_new (); g_signal_connect (cell, "toggled", G_CALLBACK (gsb_payment_method_config_toggled), payment_method_treeview); gtk_cell_renderer_toggle_set_radio ( GTK_CELL_RENDERER_TOGGLE(cell), TRUE ); g_object_set (cell, "xalign", 0.5, NULL); column = gtk_tree_view_column_new ( ); gtk_tree_view_column_set_alignment ( column, 0.5 ); gtk_tree_view_column_pack_end ( column, cell, TRUE ); gtk_tree_view_column_set_title ( column, _("Default") ); gtk_tree_view_column_set_attributes (column, cell, "active", PAYMENT_METHODS_DEFAULT_COLUMN, "activatable", PAYMENT_METHODS_ACTIVABLE_COLUMN, "visible", PAYMENT_METHODS_VISIBLE_COLUMN, NULL); gtk_tree_view_append_column ( GTK_TREE_VIEW(payment_method_treeview), column); /* Numbering */ cell = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new ( ); gtk_tree_view_column_pack_end ( column, cell, TRUE ); gtk_tree_view_column_set_title ( column, _("Numbering") ); gtk_tree_view_column_set_attributes (column, cell, "text", PAYMENT_METHODS_NUMBERING_COLUMN, NULL); gtk_tree_view_append_column ( GTK_TREE_VIEW(payment_method_treeview), column); /* expand all rows after the treeview widget has been realized */ g_signal_connect (payment_method_treeview, "realize", G_CALLBACK (gtk_tree_view_expand_all), NULL); gtk_container_add ( GTK_CONTAINER ( scrolled_window ), payment_method_treeview ); gsb_payment_method_config_fill_list (GTK_TREE_MODEL (payment_method_model)); /* Create "Add" & "Remove" buttons */ vbox = gtk_vbox_new ( FALSE, 6 ); gtk_box_pack_start ( GTK_BOX ( hbox ), vbox, FALSE, FALSE, 0 ); /* "Add payment method" button */ bouton_ajouter_type = gtk_button_new_from_stock (GTK_STOCK_ADD); gtk_button_set_relief ( GTK_BUTTON ( bouton_ajouter_type ), GTK_RELIEF_NONE ); g_signal_connect ( G_OBJECT ( bouton_ajouter_type ), "clicked", G_CALLBACK (gsb_payment_method_config_add), payment_method_treeview ); gtk_box_pack_start ( GTK_BOX ( vbox ), bouton_ajouter_type, TRUE, FALSE, 5 ); /* "Remove payment method" button */ payment_remove_button = gtk_button_new_from_stock (GTK_STOCK_REMOVE); gtk_button_set_relief ( GTK_BUTTON ( payment_remove_button ), GTK_RELIEF_NONE ); gtk_widget_set_sensitive ( payment_remove_button, FALSE ); g_signal_connect ( G_OBJECT ( payment_remove_button ), "clicked", G_CALLBACK (gsb_payment_method_config_remove), payment_method_treeview ); gtk_box_pack_start ( GTK_BOX ( vbox ), payment_remove_button, TRUE, FALSE, 5 ); /* Payment method details */ details_paddingbox = new_paddingbox_with_title (vbox_pref, FALSE, _("Payment method details")); gtk_widget_set_sensitive ( details_paddingbox, FALSE ); /* Payment method name */ table = gtk_table_new ( 3, 3, FALSE ); gtk_table_set_col_spacings ( GTK_TABLE ( table ), 6 ); gtk_table_set_row_spacings ( GTK_TABLE ( table ), 6 ); gtk_box_pack_start ( GTK_BOX ( details_paddingbox ), table, TRUE, TRUE, 6 ); label = gtk_label_new ( _("Name: ") ); gtk_misc_set_alignment (GTK_MISC (label), 0, 1); gtk_label_set_justify ( GTK_LABEL(label), GTK_JUSTIFY_RIGHT ); gtk_table_attach ( GTK_TABLE ( table ), label, 0, 1, 0, 1, GTK_SHRINK | GTK_FILL, 0, 0, 0 ); payment_name_entry = gsb_autofunc_entry_new ( NULL, G_CALLBACK (gsb_payment_method_config_name_changed), payment_method_treeview, G_CALLBACK (gsb_data_payment_set_name), 0 ); gtk_widget_set_size_request ( payment_name_entry, width_entry, -1 ); gtk_table_attach ( GTK_TABLE ( table ), payment_name_entry, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0 ); /* button show entry, automatic numbering button will be shown only if entry is showed */ button_show_entry = gsb_autofunc_checkbutton_new ( _("Need entry field"), FALSE, G_CALLBACK (gsb_payment_method_config_show_entry_changed), payment_method_treeview, G_CALLBACK (gsb_data_payment_set_show_entry), 0 ); gtk_table_attach ( GTK_TABLE ( table ), button_show_entry, 2, 3, 0, 1, GTK_SHRINK | GTK_FILL, 0, 0, 0 ); /* Automatic numbering */ label = gtk_label_new ( _("Automatic numbering: ") ); gtk_misc_set_alignment (GTK_MISC (label), 0, 1); gtk_label_set_justify ( GTK_LABEL(label), GTK_JUSTIFY_RIGHT ); gtk_table_attach ( GTK_TABLE ( table ), label, 0, 1, 1, 2, GTK_SHRINK | GTK_FILL, 0, 0, 0 ); payment_last_number_entry = gsb_autofunc_spin_new ( 0, G_CALLBACK (gsb_payment_method_config_auto_entry_changed), payment_method_treeview, G_CALLBACK (gsb_data_payment_set_last_number_from_int), 0 ); gtk_widget_set_size_request ( payment_last_number_entry, width_entry, -1 ); gtk_table_attach ( GTK_TABLE ( table ), payment_last_number_entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0 ); /* button automatic numbering, activate it sensitive the automatic numbering entry */ button_auto_numbering = gsb_autofunc_checkbutton_new ( _("Activate"), FALSE, G_CALLBACK (gsb_payment_method_config_auto_button_changed), payment_method_treeview, G_CALLBACK (gsb_data_payment_set_automatic_numbering), 0 ); gtk_table_attach ( GTK_TABLE ( table ), button_auto_numbering, 2, 3, 1, 2, GTK_SHRINK | GTK_FILL, 0, 0, 0 ); /* Payment method method_ptr */ label = gtk_label_new ( _("Type: ") ); gtk_misc_set_alignment (GTK_MISC (label), 0, 1); gtk_label_set_justify ( GTK_LABEL(label), GTK_JUSTIFY_RIGHT ); gtk_table_attach ( GTK_TABLE ( table ), label, 0, 1, 2, 3, GTK_SHRINK | GTK_FILL, 0, 0, 0 ); /* Create menu */ payment_sign_button = gtk_option_menu_new (); menu = gtk_menu_new(); /* Neutral method_ptr */ item = gtk_menu_item_new_with_label ( _("Neutral") ); g_signal_connect ( G_OBJECT ( item ), "activate", G_CALLBACK ( gsb_payment_method_config_sign_changed ), GINT_TO_POINTER (GSB_PAYMENT_NEUTRAL)); gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ), item ); /* Debit method_ptr */ item = gtk_menu_item_new_with_label ( _("Debit") ); g_signal_connect ( G_OBJECT ( item ), "activate", G_CALLBACK ( gsb_payment_method_config_sign_changed ), GINT_TO_POINTER (GSB_PAYMENT_DEBIT)); gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ), item ); /* Credit method_ptr */ item = gtk_menu_item_new_with_label ( _("Credit") ); g_signal_connect ( G_OBJECT ( item ), "activate", G_CALLBACK ( gsb_payment_method_config_sign_changed ), GINT_TO_POINTER (GSB_PAYMENT_CREDIT)); gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ), item ); /* Set menu */ gtk_option_menu_set_menu ( GTK_OPTION_MENU ( payment_sign_button ), menu ); gtk_table_attach ( GTK_TABLE ( table ), payment_sign_button, 1, 3, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 0 ); /** Do not set this tab sensitive is no account file is opened. */ if ( !gsb_data_account_get_accounts_amount () ) { gtk_widget_set_sensitive ( vbox_pref, FALSE ); } return ( vbox_pref ); }
/** * create the config widget for the reconcile * to choose the order of the method of payment to sort the list * while reconciling * * \param * * \return a GtkWidget containing the config widget */ GtkWidget *gsb_reconcile_sort_config_create ( void ) { GtkWidget *hbox, *scrolled_window; GtkWidget *vbox_pref, *paddingbox; GtkTreeViewColumn *column; GtkCellRenderer *cell; GtkWidget *vbox_fleches_tri; GtkTreeStore *reconcile_model; GtkTreeSelection *reconcile_selection; vbox_pref = new_vbox_with_title_and_icon ( _("Sort for reconciliation"), "reconciliationlg.png" ); paddingbox = new_paddingbox_with_title ( vbox_pref, TRUE, _("Reconciliation: sort transactions") ); /* la partie du milieu est une hbox avec les types */ hbox = gtk_hbox_new ( FALSE, 5 ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), hbox, TRUE, TRUE, 0 ); /* mise en place de la liste qui contient les types classés */ scrolled_window = gtk_scrolled_window_new ( NULL, NULL ); gtk_box_pack_start ( GTK_BOX ( hbox ), scrolled_window, TRUE, TRUE, 0); gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW ( scrolled_window ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); reconcile_model = gtk_tree_store_new ( NUM_RECONCILIATION_SORT_COLUMNS, G_TYPE_STRING, /* Name */ G_TYPE_BOOLEAN, /* Visible */ G_TYPE_BOOLEAN, /* Sort by method of payment */ G_TYPE_BOOLEAN, /* Split neutrals */ G_TYPE_INT, /* Account number */ G_TYPE_INT, /* payment number */ G_TYPE_BOOLEAN ); /* sensitive line */ reconcile_treeview = gtk_tree_view_new_with_model ( GTK_TREE_MODEL (reconcile_model) ); g_object_unref (G_OBJECT(reconcile_model)); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (reconcile_treeview), TRUE); gtk_tree_selection_set_mode ( gtk_tree_view_get_selection (GTK_TREE_VIEW (reconcile_treeview)), GTK_SELECTION_SINGLE ); reconcile_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (reconcile_treeview)); g_signal_connect (reconcile_selection, "changed", G_CALLBACK (gsb_reconcile_sort_config_select), reconcile_model); /* Name */ cell = gtk_cell_renderer_text_new ( ); column = gtk_tree_view_column_new ( ); gtk_tree_view_column_pack_end ( column, cell, TRUE ); gtk_tree_view_column_set_title ( column, _("Payment method") ); gtk_tree_view_column_set_attributes (column, cell, "text", RECONCILIATION_SORT_NAME_COLUMN, "sensitive", RECONCILIATION_SORT_SENSITIVE_COLUMN, NULL); gtk_tree_view_column_set_expand ( column, TRUE ); gtk_tree_view_append_column ( GTK_TREE_VIEW(reconcile_treeview), column); /* Sort by date */ cell = gtk_cell_renderer_toggle_new (); gtk_cell_renderer_toggle_set_radio ( GTK_CELL_RENDERER_TOGGLE(cell), FALSE ); g_signal_connect (cell, "toggled", G_CALLBACK (gsb_reconcile_sort_config_payment_toggled), reconcile_treeview); g_object_set (cell, "xalign", 0.5, NULL); column = gtk_tree_view_column_new ( ); gtk_tree_view_column_set_alignment ( column, 0.5 ); gtk_tree_view_column_pack_end ( column, cell, TRUE ); gtk_tree_view_column_set_title ( column, _("Sort by payment method") ); gtk_tree_view_column_set_attributes (column, cell, "active", RECONCILIATION_SORT_SORT_COLUMN, "activatable", RECONCILIATION_SORT_VISIBLE_COLUMN, "visible", RECONCILIATION_SORT_VISIBLE_COLUMN, NULL); gtk_tree_view_column_set_expand ( column, TRUE ); gtk_tree_view_append_column ( GTK_TREE_VIEW(reconcile_treeview), column); /* Split neutral payment methods */ cell = gtk_cell_renderer_toggle_new (); gtk_cell_renderer_toggle_set_radio ( GTK_CELL_RENDERER_TOGGLE(cell), FALSE ); g_signal_connect (cell, "toggled", G_CALLBACK (gsb_reconcile_sort_config_neutral_toggled), reconcile_treeview); g_object_set (cell, "xalign", 0.5, NULL); column = gtk_tree_view_column_new ( ); gtk_tree_view_column_set_alignment ( column, 0.5 ); gtk_tree_view_column_pack_end ( column, cell, TRUE ); gtk_tree_view_column_set_title ( column, _("Split neutral payment methods") ); gtk_tree_view_column_set_attributes (column, cell, "active", RECONCILIATION_SORT_SPLIT_NEUTRAL_COLUMN, "activatable", RECONCILIATION_SORT_VISIBLE_COLUMN, "visible", RECONCILIATION_SORT_VISIBLE_COLUMN, NULL); gtk_tree_view_column_set_expand ( column, TRUE ); gtk_tree_view_append_column ( GTK_TREE_VIEW(reconcile_treeview), column); /* Various remaining settings */ gtk_scrolled_window_set_shadow_type ( GTK_SCROLLED_WINDOW ( scrolled_window ), GTK_SHADOW_IN); gtk_container_add ( GTK_CONTAINER ( scrolled_window ), reconcile_treeview ); gsb_reconcile_sort_config_fill(); /* set the arrows under the list */ vbox_fleches_tri = gtk_hbox_new ( TRUE, 10 ); gtk_box_pack_start ( GTK_BOX (paddingbox), vbox_fleches_tri, FALSE, FALSE, 0); button_move_up = gtk_button_new_from_stock (GTK_STOCK_GO_UP); gtk_button_set_relief ( GTK_BUTTON ( button_move_up ), GTK_RELIEF_NONE ); g_signal_connect ( G_OBJECT ( button_move_up ), "clicked", G_CALLBACK (gsb_reconcile_sort_config_move_up), reconcile_treeview ); gtk_box_pack_start ( GTK_BOX (vbox_fleches_tri), button_move_up, FALSE, FALSE, 0 ); gtk_widget_set_sensitive ( button_move_up, FALSE ); button_move_down = gtk_button_new_from_stock (GTK_STOCK_GO_DOWN); gtk_button_set_relief ( GTK_BUTTON ( button_move_down ), GTK_RELIEF_NONE ); g_signal_connect ( G_OBJECT ( button_move_down ), "clicked", G_CALLBACK (gsb_reconcile_sort_config_move_down), reconcile_treeview); gtk_box_pack_start ( GTK_BOX (vbox_fleches_tri), button_move_down, FALSE, FALSE, 0 ); gtk_widget_set_sensitive ( button_move_down, FALSE ); if ( !gsb_data_account_get_accounts_amount () ) { gtk_widget_set_sensitive ( vbox_pref, FALSE ); } return vbox_pref; }
/** * 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; }