/** * create the box for configuring the form, * append that box into the vbox_parent * * \param vbox_parent the box into we want to make the configuration box * * \return * */ void gsb_form_config_make_configuration_box ( GtkWidget *vbox_parent ) { GtkWidget *sw; GtkWidget *hbox; GtkWidget *paddingbox; GtkListStore* list_store; /* create the paddingbox into the parent */ paddingbox = new_paddingbox_with_title ( vbox_parent, TRUE, _("Form structure preview")); /* we can organize the form * either the same for all the accounts * either each account has its own configuration */ hbox = gtk_hbox_new ( FALSE, 5 ); gtk_box_pack_start ( GTK_BOX (paddingbox), hbox, FALSE, FALSE, 0 ); /* the accounts option_menu */ accounts_combobox = gsb_account_create_combo_list ( G_CALLBACK ( gsb_form_config_change_account_choice ), NULL, FALSE ); /*create the scolled window for tree_view */ sw = gtk_scrolled_window_new ( NULL, NULL); gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW ( sw ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start ( GTK_BOX ( paddingbox), sw, TRUE, TRUE, 0 ); /* create the tree_view */ list_store = gsb_form_config_create_store (); form_config_tree_view = gsb_form_config_create_tree_view (list_store); g_object_unref (G_OBJECT(list_store)); gtk_scrolled_window_add_with_viewport ( GTK_SCROLLED_WINDOW ( sw ), form_config_tree_view ); /* set the buttons line to increase/decrease the form */ gtk_box_pack_start ( GTK_BOX ( paddingbox ), gsb_form_config_create_sizing_buttons_line (), FALSE, FALSE, 0 ); /* set the box with the buttons */ paddingbox = new_paddingbox_with_title ( vbox_parent, FALSE, _("Form structure content") ); gtk_box_pack_start ( GTK_BOX ( paddingbox ), gsb_form_config_create_buttons_table (), FALSE, FALSE, 0 ); gtk_widget_show_all (paddingbox); }
/** * create the page to create new reconciles * * \param * * \return a GtkWidget, the page to the assistant * */ static GtkWidget *gsb_assistant_reconcile_config_page_new_reconcile ( void ) { GtkWidget *page; GtkWidget *label; GtkWidget *paddingbox; GtkWidget *table; GtkWidget *button; GtkWidget *hbox; page = gtk_box_new ( GTK_ORIENTATION_VERTICAL, 0 ); gtk_container_set_border_width ( GTK_CONTAINER(page), 12 ); paddingbox = new_paddingbox_with_title ( page, FALSE, _("Fill the fields and click the button \"Create the new reconciliation\"")); /* create the table, this is the same as the reconcile config, * but here it's to create new ones */ table = gtk_table_new ( 4, 3, 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 (paddingbox), table, FALSE, FALSE, 0 ); /* set the name */ label = gtk_label_new ( _("Reconciliation reference: ") ); 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 ); reconcile_name_entry = gtk_entry_new (); gtk_table_attach ( GTK_TABLE ( table ), reconcile_name_entry, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 10, 0 ); /* set the choice of account */ label = gtk_label_new ( _("Account: ") ); 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, 2, 3, 0, 1, GTK_SHRINK | GTK_FILL, 0, 10, 0 ); reconcile_account_button = gsb_account_create_combo_list ( NULL, NULL, TRUE ); gtk_combo_box_set_active ( GTK_COMBO_BOX (reconcile_account_button), 0 ); gtk_table_attach ( GTK_TABLE ( table ), reconcile_account_button, 3, 4, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0 ); /* set the initial date */ label = gtk_label_new ( _("Initial date: ") ); 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 ); reconcile_init_date_entry = gsb_calendar_entry_new (FALSE); gtk_table_attach ( GTK_TABLE ( table ), reconcile_init_date_entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 10, 0 ); /* set the final date */ label = gtk_label_new ( _("Final date: ") ); 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, 2, 3, GTK_SHRINK | GTK_FILL, 0, 0, 0 ); reconcile_final_date_entry = gsb_calendar_entry_new (FALSE); gtk_table_attach ( GTK_TABLE ( table ), reconcile_final_date_entry, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 10, 0 ); /* set the initial balance */ label = gtk_label_new ( _("Initial balance: ") ); 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, 2, 3, 1, 2, GTK_SHRINK | GTK_FILL, 0, 10, 0 ); reconcile_init_balance_entry = gtk_entry_new (); gtk_table_attach ( GTK_TABLE ( table ), reconcile_init_balance_entry, 3, 4, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0 ); /* set the final balance */ label = gtk_label_new ( _("Final balance: ") ); 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, 2, 3, 2, 3, GTK_SHRINK | GTK_FILL, 0, 10, 0 ); reconcile_final_balance_entry = gtk_entry_new (); gtk_table_attach ( GTK_TABLE ( table ), reconcile_final_balance_entry, 3, 4, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 0 ); /* create the button */ hbox = gtk_box_new ( GTK_ORIENTATION_HORIZONTAL, 0 ); gtk_box_set_homogeneous ( GTK_BOX ( hbox ), TRUE ); gtk_box_pack_start ( GTK_BOX (page), hbox, FALSE, FALSE, 0 ); button = gtk_button_new_with_label (_("Create the new reconciliation")); gtk_box_pack_end ( GTK_BOX (hbox), button, FALSE, FALSE, 0 ); /* create the label */ label = gtk_label_new (NULL); gtk_box_pack_start ( GTK_BOX (page), label, TRUE, TRUE, 0 ); /* if we change anything in the entries, hide the label */ g_signal_connect ( G_OBJECT (reconcile_name_entry), "changed", G_CALLBACK (gsb_assistant_reconcile_config_hide_label_error), label ); g_signal_connect ( G_OBJECT (reconcile_init_date_entry), "changed", G_CALLBACK (gsb_assistant_reconcile_config_hide_label_error), label ); g_signal_connect ( G_OBJECT (reconcile_final_date_entry), "changed", G_CALLBACK (gsb_assistant_reconcile_config_hide_label_error), label ); g_signal_connect ( G_OBJECT (reconcile_init_balance_entry), "changed", G_CALLBACK (gsb_assistant_reconcile_config_hide_label_error), label ); g_signal_connect ( G_OBJECT (reconcile_final_balance_entry), "changed", G_CALLBACK (gsb_assistant_reconcile_config_hide_label_error), label ); /* connect the button and give the message label as param */ g_signal_connect ( G_OBJECT (button), "clicked", G_CALLBACK (gsb_assistant_reconcile_config_page_add_new_reconcile), label ); gtk_widget_show_all (page); return page; }
/** * create the scheduled part : that widgets are created at the beginning * and normally never destroyed, they are showed only for * scheduled transactions * Cela ne fonctionne pas : tous les widgets sont détruits par la * fonction gsb_form_create_widgets ( ) * * \param table a GtkTable with the dimension SCHEDULED_HEIGHT*SCHEDULED_WIDTH to be filled * * \return FALSE * */ gboolean gsb_form_scheduler_create ( GtkWidget *table ) { gint row, column; struct_element *element; devel_debug (NULL); if (!table) return FALSE; /* just in case... be sure that not created */ if (scheduled_element_list) gsb_form_scheduler_free_list ( ); /* check the dimensions, * if problem give a warning message but continue the program with changing the values */ g_object_get ( G_OBJECT (table), "n-columns", &column, "n-rows", &row, NULL ); if ( column != SCHEDULED_WIDTH || row != SCHEDULED_HEIGHT ) { warning_debug ( _("gsb_form_scheduler_create is called with a bad table,\n" "the number of rows or columns is not good.\n" "The function will resize the table to the correct values but " "should check that warning.")); gtk_table_resize ( GTK_TABLE (table), SCHEDULED_HEIGHT, SCHEDULED_WIDTH ); } /* ok, now fill the form * we play with height and width, but for now it's fix : 6 columns and 1 line */ for ( row=0 ; row < SCHEDULED_HEIGHT ; row++ ) for ( column=0 ; column < SCHEDULED_WIDTH ; column++ ) { gint element_number; GtkWidget *widget = NULL; const gchar *tooltip_text = NULL; gchar *text_auto [] = { _("Manual"), _("Automatic"), NULL }; gchar *text_frequency [] = { _("Once"), _("Weekly"), _("Monthly"), _("Bimonthly"), _("Quarterly"), _("Yearly"), _("Custom"), NULL }; gchar *text_frequency_user [] = { _("Days"), _("Weeks"), _("Months"), _("Years"), NULL }; element_number = row*SCHEDULED_WIDTH + column; switch ( element_number ) { case SCHEDULED_FORM_ACCOUNT: widget = gsb_account_create_combo_list ( G_CALLBACK ( gsb_form_scheduler_change_account ), NULL, FALSE); gtk_combo_box_set_active ( GTK_COMBO_BOX (widget), 0 ); tooltip_text = _("Choose the account"); break; case SCHEDULED_FORM_AUTO: widget = gsb_combo_box_new_with_index ( text_auto, NULL, NULL ); tooltip_text = _("Automatic/manual scheduled transaction"); break; case SCHEDULED_FORM_FREQUENCY_BUTTON: widget = gsb_combo_box_new_with_index ( text_frequency, G_CALLBACK (gsb_form_scheduler_frequency_button_changed), NULL ); tooltip_text = _("Frequency"); break; case SCHEDULED_FORM_LIMIT_DATE: widget = gsb_calendar_entry_new (FALSE); g_signal_connect ( G_OBJECT (widget), "button-press-event", G_CALLBACK (gsb_form_scheduler_button_press_event), GINT_TO_POINTER (element_number)); g_signal_connect ( G_OBJECT (widget), "focus-in-event", G_CALLBACK (gsb_form_entry_get_focus), GINT_TO_POINTER (element_number)); g_signal_connect_after ( G_OBJECT (widget), "focus-out-event", G_CALLBACK (gsb_form_scheduler_entry_lose_focus), GINT_TO_POINTER (element_number)); tooltip_text = _("Limit date"); break; case SCHEDULED_FORM_FREQUENCY_USER_ENTRY: widget = gtk_entry_new (); g_signal_connect ( G_OBJECT (widget), "focus-in-event", G_CALLBACK (gsb_form_entry_get_focus), GINT_TO_POINTER (element_number)); g_signal_connect_after ( G_OBJECT (widget), "focus-out-event", G_CALLBACK (gsb_form_scheduler_entry_lose_focus), GINT_TO_POINTER (element_number)); tooltip_text = _("Own frequency"); break; case SCHEDULED_FORM_FREQUENCY_USER_BUTTON: widget = gsb_combo_box_new_with_index ( text_frequency_user, NULL, NULL ); tooltip_text = _("Custom frequency"); break; } if (!widget) continue; if (tooltip_text) gtk_widget_set_tooltip_text ( GTK_WIDGET (widget), tooltip_text); /* save the element */ element = g_malloc0 (sizeof (struct_element)); element -> element_number = element_number; element -> element_widget = widget; scheduled_element_list = g_slist_append ( scheduled_element_list, element ); /* set in the form */ gtk_table_attach ( GTK_TABLE (table), widget, column, column+1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); } gsb_form_scheduler_clean ( ); return FALSE; }