/******************************************************* * get_filter_times * * get the start and end times from the dialog *******************************************************/ static void get_filter_times (CsvExportInfo *info) { time64 time_val; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(info->csvd.start_date_choose))) { time_val = gnc_date_edit_get_date (GNC_DATE_EDIT(info->csvd.start_date)); time_val = gnc_time64_get_day_start (time_val); info->csvd.start_time = time_val; } else { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(info->csvd.start_date_today))) info->csvd.start_time = gnc_time64_get_today_start(); else info->csvd.start_time = 0; } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(info->csvd.end_date_choose))) { time_val = gnc_date_edit_get_date (GNC_DATE_EDIT(info->csvd.end_date)); time_val = gnc_time64_get_day_end (time_val); info->csvd.end_time = time_val; } else { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(info->csvd.end_date_today))) info->csvd.end_time = gnc_time64_get_today_end(); else info->csvd.end_time = gnc_time (NULL); } }
void gnc_prices_dialog_remove_old_clicked (GtkWidget *widget, gpointer data) { PricesDialog *pdb_dialog = data; GtkBuilder *builder; GtkWidget *dialog, *button, *date, *label, *box; gint result; gboolean delete_user, delete_last; ENTER(" "); builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-price.glade", "Deletion Date"); dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Deletion Date")); box = GTK_WIDGET(gtk_builder_get_object (builder, "date_hbox")); date = gnc_date_edit_new (time (NULL), FALSE, FALSE); gtk_box_pack_start (GTK_BOX (box), date, TRUE, TRUE, 0); gtk_widget_show (date); gtk_entry_set_activates_default(GTK_ENTRY(GNC_DATE_EDIT(date)->date_entry), TRUE); label = GTK_WIDGET(gtk_builder_get_object (builder, "date_label")); gnc_date_make_mnemonic_target (GNC_DATE_EDIT(date), label); gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, pdb_dialog); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (pdb_dialog->dialog)); result = gtk_dialog_run (GTK_DIALOG (dialog)); if (result == GTK_RESPONSE_OK) { Timespec ts; DEBUG("deleting prices"); ts.tv_sec = gnc_date_edit_get_date (GNC_DATE_EDIT (date)); ts.tv_nsec = 0; button = GTK_WIDGET(gtk_builder_get_object (builder, "delete_manual")); delete_user = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); button = GTK_WIDGET(gtk_builder_get_object (builder, "delete_last")); delete_last = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); gnc_pricedb_remove_old_prices(pdb_dialog->price_db, ts, delete_user, delete_last); } gtk_widget_destroy(dialog); LEAVE(" "); }
static void gnc_date_edit_dispose (GObject *object) { GNCDateEdit *gde; g_return_if_fail (object != NULL); g_return_if_fail (GNC_IS_DATE_EDIT (object)); gde = GNC_DATE_EDIT (object); if (gde->disposed) return; gde->disposed = TRUE; /* Only explicitly destroy the toplevel elements */ gtk_widget_destroy (GTK_WIDGET(gde->date_entry)); gde->date_entry = NULL; gtk_widget_destroy (GTK_WIDGET(gde->date_button)); gde->date_button = NULL; gtk_widget_destroy (GTK_WIDGET(gde->time_entry)); gde->time_entry = NULL; gtk_widget_destroy (GTK_WIDGET(gde->time_combo)); gde->time_combo = NULL; if (G_OBJECT_CLASS (parent_class)->dispose) (* G_OBJECT_CLASS (parent_class)->dispose) (object); }
void gnc_dialog_date_close_ok_cb (GtkWidget *widget, gpointer user_data) { DialogDateClose *ddc = user_data; if (ddc->acct_combo) { Account *acc; acc = gnc_account_sel_get_account( GNC_ACCOUNT_SEL(ddc->acct_combo) ); if (!acc) { gnc_error_dialog (GTK_WINDOW (ddc->dialog), "%s", _("No Account selected. Please try again.")); return; } if (xaccAccountGetPlaceholder (acc)) { gnc_error_dialog (GTK_WINDOW (ddc->dialog), "%s", _("Placeholder account selected. Please try again.")); return; } ddc->acct = acc; } if (ddc->post_date) *(ddc->ts2) = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (ddc->post_date)); if (ddc->date) { if (ddc->terms) ddc->ts->tv_sec = gncBillTermComputeDueDate (ddc->terms, ddc->ts2->tv_sec); else *(ddc->ts) = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (ddc->date)); } if (ddc->memo_entry && ddc->memo) *(ddc->memo) = gtk_editable_get_chars (GTK_EDITABLE (ddc->memo_entry), 0, -1); if (ddc->question_check) ddc->answer = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ddc->question_check)); ddc->retval = TRUE; }
static void post_date_changed_cb (GNCDateEdit *gde, gpointer d) { DialogDateClose *ddc = d; Timespec post_date; Timespec due_date = {0,0}; post_date = gnc_date_edit_get_date_ts (gde); due_date.tv_sec = gncBillTermComputeDueDate (ddc->terms, post_date.tv_sec); gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), due_date); }
void gnc_prices_dialog_remove_old_clicked (GtkWidget *widget, gpointer data) { PricesDialog *pdb_dialog = data; GladeXML *xml; GtkWidget *dialog, *button, *date, *label; gint result; gboolean delete_user, delete_last; ENTER(" "); xml = gnc_glade_xml_new ("price.glade", "Deletion Date"); dialog = glade_xml_get_widget (xml, "Deletion Date"); date = glade_xml_get_widget (xml, "date"); label = glade_xml_get_widget (xml, "date_label"); gnc_date_make_mnemonic_target (GNC_DATE_EDIT(date), label); glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, pdb_dialog); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (pdb_dialog->dialog)); result = gtk_dialog_run (GTK_DIALOG (dialog)); if (result == GTK_RESPONSE_OK) { Timespec ts; DEBUG("deleting prices"); ts.tv_sec = gnc_date_edit_get_date (GNC_DATE_EDIT (date)); ts.tv_nsec = 0; button = glade_xml_get_widget (xml, "delete_manual"); delete_user = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); button = glade_xml_get_widget (xml, "delete_last"); delete_last = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); gnc_pricedb_remove_old_prices(pdb_dialog->price_db, ts, delete_user, delete_last); } gtk_widget_destroy(dialog); LEAVE(" "); }
/** Set a property specific to this GncDateEdit object. This is * nothing more than a dispatch function for routines that can be * called directly. It has the nice feature of allowing a new widget * to be created with a varargs list specifying the properties, * instead of having to explicitly call each property function. * * @internal */ static void gnc_date_edit_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { GNCDateEdit *date_edit = GNC_DATE_EDIT (object); switch (prop_id) { case PROP_TIME: gnc_date_edit_set_time_internal (date_edit, g_value_get_int64(value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; } }
static gboolean gnc_date_edit_button_released (GtkWidget *widget, GdkEventButton *event, gpointer data) { GNCDateEdit *gde = GNC_DATE_EDIT(data); GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event); gboolean popup_in_progress = FALSE; ENTER("widget=%p, ewidget=%p, event=%p, gde=%p", widget, ewidget, event, gde); if (gde->popup_in_progress) { popup_in_progress = TRUE; gde->popup_in_progress = FALSE; } /* Propagate releases on the calendar. */ if (ewidget == gde->calendar) { LEAVE("Button release on calendar."); return FALSE; } if (ewidget == gde->date_button) { /* Pop down if we're up and it isn't due to the preceding press. */ if (!popup_in_progress && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gde->date_button))) { gnc_date_edit_popdown (gde); LEAVE("Release on button, not in progress. Popped down."); return TRUE; } LEAVE("Button release on button. Allowing."); return FALSE; } /* Pop down on a release anywhere else. */ gnc_date_edit_popdown (gde); LEAVE("Release not on button or calendar. Popping down."); return TRUE; }
static void something_changed( GtkWidget *wid, gpointer d ) { UIPeriodType pt; GDate start; gboolean show_last, use_wd; GncRecurrence *gr = GNC_RECURRENCE(d); pt = get_pt_ui(gr); gnc_date_edit_get_gdate(GNC_DATE_EDIT(gr->gde_start), &start); if (pt == GNCR_MONTH) g_object_set(G_OBJECT(gr->nth_weekday), "visible", TRUE, NULL); else { g_object_set(G_OBJECT(gr->nth_weekday), "visible", FALSE, NULL); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(gr->nth_weekday), FALSE); } use_wd = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(gr->nth_weekday)); //TODO: change label /* The case under which we show the "end of month" flag is very narrow, because we can almost always DTRT without it. */ if (pt == GNCR_MONTH) { if (use_wd) show_last = is_ambiguous_relative(&start); else show_last = is_ambiguous_absolute(&start); } else { show_last = FALSE; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gr->gcb_eom), FALSE); } g_object_set(G_OBJECT(gr->gcb_eom), "visible", show_last, NULL); g_signal_emit_by_name(d, "changed"); }
void gnc_recurrence_set(GncRecurrence *gr, const Recurrence *r) { PeriodType pt; guint mult; GDate start; g_return_if_fail(gr && r); pt = recurrenceGetPeriodType(r); mult = recurrenceGetMultiplier(r); start = recurrenceGetDate(r); gtk_spin_button_set_value(gr->gsb_mult, (gdouble) mult); // is there some better way? { time64 t; t = gnc_time64_get_day_start_gdate (&start); gnc_date_edit_set_time (GNC_DATE_EDIT(gr->gde_start), t); } set_pt_ui(gr, pt); }
/* This function is a customized gtk_combo_box_list_button_pressed(). */ static gboolean gnc_date_edit_button_pressed (GtkWidget *widget, GdkEventButton *event, gpointer data) { GNCDateEdit *gde = GNC_DATE_EDIT(data); GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event); ENTER("widget=%p, ewidget=%p, event=%p, gde=%p", widget, ewidget, event, gde); /* While popped up, ignore presses outside the popup window. */ if (ewidget == gde->cal_popup) { LEAVE("Press on calendar. Ignoring."); return TRUE; } /* If the press isn't to make the popup appear, just propagate it. */ if (ewidget != gde->date_button || gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gde->date_button))) { LEAVE("Press, not on popup button, or while popup is raised."); return FALSE; } if (!gtk_widget_has_focus (gde->date_button)) gtk_widget_grab_focus (gde->date_button); gde->popup_in_progress = TRUE; gnc_date_edit_popup (gde); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gde->date_button), TRUE); LEAVE("Popup in progress."); return TRUE; }
static gint sxftd_init( SXFromTransInfo *sxfti ) { GtkWidget *w; const char *transName; gint pos; GList *schedule = NULL; time64 start_tt; struct tm *tmpTm; GDate date, nextDate; if ( ! sxfti->sx ) { return -1; } if ( ! sxfti->trans ) { return -2; } if ( xaccTransIsOpen( sxfti->trans ) ) { return SXFTD_ERRNO_OPEN_XACTION; } /* Setup Widgets */ { sxfti->ne_but = GTK_TOGGLE_BUTTON(gtk_builder_get_object(sxfti->builder, "never_end_button")); sxfti->ed_but = GTK_TOGGLE_BUTTON(gtk_builder_get_object(sxfti->builder, "end_on_date_button")); sxfti->oc_but = GTK_TOGGLE_BUTTON(gtk_builder_get_object(sxfti->builder, "n_occurrences_button")); sxfti->n_occurences = GTK_ENTRY(gtk_builder_get_object(sxfti->builder, "n_occurrences_entry")); } /* Get the name from the transaction, try that as the initial SX name. */ transName = xaccTransGetDescription( sxfti->trans ); xaccSchedXactionSetName( sxfti->sx, transName ); sxfti->name = GTK_ENTRY(gtk_builder_get_object(sxfti->builder, "name_entry" )); pos = 0; gtk_editable_insert_text( GTK_EDITABLE(sxfti->name), transName, (strlen(transName) * sizeof(char)), &pos ); sxfti_attach_callbacks(sxfti); /* Setup the example calendar and related data structures. */ { int num_marks = SXFTD_EXCAL_NUM_MONTHS * 31; w = GTK_WIDGET(gtk_builder_get_object(sxfti->builder, "ex_cal_frame" )); sxfti->dense_cal_model = gnc_dense_cal_store_new(num_marks); sxfti->example_cal = GNC_DENSE_CAL(gnc_dense_cal_new_with_model(GNC_DENSE_CAL_MODEL(sxfti->dense_cal_model))); g_object_ref_sink(sxfti->example_cal); g_assert(sxfti->example_cal); gnc_dense_cal_set_num_months( sxfti->example_cal, SXFTD_EXCAL_NUM_MONTHS ); gnc_dense_cal_set_months_per_col( sxfti->example_cal, SXFTD_EXCAL_MONTHS_PER_COL ); gtk_container_add( GTK_CONTAINER(w), GTK_WIDGET(sxfti->example_cal) ); } /* Setup the start and end dates as GNCDateEdits */ { GtkWidget *paramTable = GTK_WIDGET(gtk_builder_get_object(sxfti->builder, "param_table" )); sxfti->startDateGDE = GNC_DATE_EDIT( gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE)); gtk_table_attach( GTK_TABLE(paramTable), GTK_WIDGET( sxfti->startDateGDE ), 1, 2, 2, 3, (GTK_EXPAND | GTK_FILL), GTK_FILL, 0, 0 ); g_signal_connect( sxfti->startDateGDE, "date-changed", G_CALLBACK( sxftd_update_excal_adapt ), sxfti ); } { GtkWidget *endDateBox = GTK_WIDGET(gtk_builder_get_object(sxfti->builder, "end_date_hbox" )); sxfti->endDateGDE = GNC_DATE_EDIT( gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE)); gtk_box_pack_start( GTK_BOX( endDateBox ), GTK_WIDGET( sxfti->endDateGDE ), TRUE, TRUE, 0 ); g_signal_connect( sxfti->endDateGDE, "date-changed", G_CALLBACK( sxftd_update_excal_adapt ), sxfti ); } /* Setup the initial start date for user display/confirmation */ /* compute good initial date. */ start_tt = xaccTransGetDate( sxfti->trans ); gnc_gdate_set_time64( &date, start_tt ); sxfti->freq_combo = GTK_COMBO_BOX(gtk_builder_get_object(sxfti->builder, "freq_combo_box")); gtk_combo_box_set_active(GTK_COMBO_BOX(sxfti->freq_combo), 0); g_signal_connect( sxfti->freq_combo, "changed", G_CALLBACK(sxftd_freq_combo_changed), sxfti ); sxftd_update_schedule( sxfti, &date, &schedule); recurrenceListNextInstance(schedule, &date, &nextDate); recurrenceListFree(&schedule); start_tt = gnc_time64_get_day_start_gdate (&nextDate); gnc_date_edit_set_time( sxfti->startDateGDE, start_tt ); g_signal_connect( G_OBJECT(sxfti->name), "destroy", G_CALLBACK(sxftd_destroy), sxfti ); sxftd_update_example_cal( sxfti ); return 0; }
gboolean gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message, const char *ddue_label_message, const char *post_label_message, const char *acct_label_message, const char *question_check_message, gboolean ok_is_default, gboolean set_default_acct, GList * acct_types, GList * acct_commodities, QofBook *book, GncBillTerm *terms, /* Returned Data... */ Timespec *ddue, Timespec *post, char **memo, Account **acct, gboolean *answer) { DialogDateClose *ddc; GtkLabel *label; GtkWidget *date_box; GtkWidget *acct_box; GtkBuilder *builder; gboolean retval; if (!message || !ddue_label_message || !post_label_message || !acct_label_message || !acct_types || !book || !ddue || !post || !acct) return FALSE; if (question_check_message && !answer) return FALSE; ddc = g_new0 (DialogDateClose, 1); ddc->ts = ddue; ddc->ts2 = post; ddc->book = book; ddc->acct_types = acct_types; ddc->acct_commodities = acct_commodities; ddc->acct = *acct; ddc->memo = memo; ddc->terms = terms; builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-date-close.glade", "date_account_dialog"); ddc->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "date_account_dialog")); ddc->memo_entry = GTK_WIDGET(gtk_builder_get_object (builder, "memo_entry")); // Set the style context for this dialog so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(ddc->dialog), "GncDateCloseDialog"); acct_box = GTK_WIDGET(gtk_builder_get_object (builder, "acct_hbox")); ddc->acct_combo = gnc_account_sel_new(); gtk_box_pack_start (GTK_BOX(acct_box), ddc->acct_combo, TRUE, TRUE, 0); date_box = GTK_WIDGET(gtk_builder_get_object (builder, "date_hbox")); ddc->date = gnc_date_edit_new (time(NULL), FALSE, FALSE); gtk_box_pack_start (GTK_BOX(date_box), ddc->date, TRUE, TRUE, 0); date_box = GTK_WIDGET(gtk_builder_get_object (builder, "post_date_box")); ddc->post_date = gnc_date_edit_new (time(NULL), FALSE, FALSE); gtk_box_pack_start (GTK_BOX(date_box), ddc->post_date, TRUE, TRUE, 0); ddc->question_check = GTK_WIDGET(gtk_builder_get_object (builder, "question_check")); if (parent) gtk_window_set_transient_for (GTK_WINDOW(ddc->dialog), GTK_WINDOW(parent)); /* Set the labels */ label = GTK_LABEL (gtk_builder_get_object (builder, "top_msg_label")); gtk_label_set_text (label, message); label = GTK_LABEL (gtk_builder_get_object (builder, "date_label")); gtk_label_set_text (label, ddue_label_message); label = GTK_LABEL (gtk_builder_get_object (builder, "postdate_label")); gtk_label_set_text (label, post_label_message); label = GTK_LABEL (gtk_builder_get_object (builder, "acct_label")); gtk_label_set_text (label, acct_label_message); if (question_check_message) { gtk_label_set_text(GTK_LABEL(gtk_bin_get_child (GTK_BIN(ddc->question_check))), question_check_message); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ddc->question_check), *answer); } else { gtk_widget_hide(ddc->question_check); gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "hide1"))); } /* Set the post date widget */ gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->post_date), *post); /* Deal with the terms handling of the due date */ if (terms) { g_signal_connect (G_OBJECT (ddc->post_date), "date_changed", G_CALLBACK (post_date_changed_cb), ddc); gtk_widget_set_sensitive (ddc->date, FALSE); post_date_changed_cb (GNC_DATE_EDIT (ddc->post_date), ddc); } else gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), *ddue); /* Setup the account widget */ fill_in_acct_info (ddc, set_default_acct); /* Setup signals */ gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, ddc); gtk_widget_show_all (ddc->dialog); /* Set the focus on the date widget */ gnc_date_grab_focus (GNC_DATE_EDIT (ddc->post_date)); ddc->retval = FALSE; while (gtk_dialog_run (GTK_DIALOG (ddc->dialog)) == GTK_RESPONSE_OK) { /* If response is OK but flag is not set, try again */ if (ddc->retval) break; } g_object_unref(G_OBJECT(builder)); gtk_widget_destroy(ddc->dialog); retval = ddc->retval; *acct = ddc->acct; if (question_check_message) *answer = ddc->answer; g_free (ddc); return retval; }
static GtkWidget * gnc_stock_split_assistant_create (StockSplitInfo *info) { GtkBuilder *builder; GtkWidget *window; builder = gtk_builder_new(); gnc_builder_add_from_file (builder , "assistant-stock-split.glade", "stock_split_assistant"); window = GTK_WIDGET(gtk_builder_get_object (builder, "stock_split_assistant")); info->window = window; // Set the style context for this assistant so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(window), "GncAssistStockSplit"); /* Enable buttons on first, second, fourth and last page. */ gtk_assistant_set_page_complete (GTK_ASSISTANT (window), GTK_WIDGET(gtk_builder_get_object(builder, "intro_page_label")), TRUE); gtk_assistant_set_page_complete (GTK_ASSISTANT (window), GTK_WIDGET(gtk_builder_get_object(builder, "stock_account_page")), TRUE); gtk_assistant_set_page_complete (GTK_ASSISTANT (window), GTK_WIDGET(gtk_builder_get_object(builder, "stock_cash_page")), TRUE); gtk_assistant_set_page_complete (GTK_ASSISTANT (window), GTK_WIDGET(gtk_builder_get_object(builder, "finish_page_label")), TRUE); /* Account page Widgets */ { GtkTreeView *view; GtkListStore *store; GtkTreeSelection *selection; GtkCellRenderer *renderer; GtkTreeViewColumn *column; info->account_view = GTK_WIDGET(gtk_builder_get_object(builder, "account_view")); view = GTK_TREE_VIEW(info->account_view); // Set grid lines option to preference gtk_tree_view_set_grid_lines (GTK_TREE_VIEW(view), gnc_tree_view_get_grid_lines_pref ()); store = gtk_list_store_new(NUM_SPLIT_COLS, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); gtk_tree_view_set_model(view, GTK_TREE_MODEL(store)); g_object_unref(store); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("Account"), renderer, "text", SPLIT_COL_FULLNAME, NULL); gtk_tree_view_append_column(view, column); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("Symbol"), renderer, "text", SPLIT_COL_MNEMONIC, NULL); gtk_tree_view_append_column(view, column); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("Shares"), renderer, "text", SPLIT_COL_SHARES, NULL); gtk_tree_view_append_column(view, column); selection = gtk_tree_view_get_selection(view); gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE); g_signal_connect (selection, "changed", G_CALLBACK (selection_changed_cb), info); } /* Details Page Widgets */ { GtkWidget *table; GtkWidget *amount; GtkWidget *date; GtkWidget *label; table = GTK_WIDGET(gtk_builder_get_object(builder, "stock_details_table")); info->description_entry = GTK_WIDGET(gtk_builder_get_object(builder, "description_entry")); date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE); gtk_grid_attach (GTK_GRID(table), date, 1, 0, 1, 1); gtk_widget_show (date); info->date_edit = date; label = GTK_WIDGET(gtk_builder_get_object(builder, "date_label")); gnc_date_make_mnemonic_target (GNC_DATE_EDIT(date), label); amount = gnc_amount_edit_new (); g_signal_connect (amount, "changed", G_CALLBACK (gnc_stock_split_details_valid_cb), info); gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (amount), TRUE); gtk_grid_attach (GTK_GRID(table), amount, 1, 1, 1, 1); gtk_widget_show (amount); info->distribution_edit = amount; label = GTK_WIDGET(gtk_builder_get_object(builder, "distribution_label")); gtk_label_set_mnemonic_widget(GTK_LABEL(label), amount); amount = gnc_amount_edit_new (); gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (amount), gnc_default_price_print_info ()); g_signal_connect (amount, "changed", G_CALLBACK (gnc_stock_split_details_valid_cb), info); gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (amount), TRUE); gtk_grid_attach (GTK_GRID(table), amount, 1, 5, 1, 1); gtk_widget_show (amount); info->price_edit = amount; label = GTK_WIDGET(gtk_builder_get_object(builder, "price_label")); gtk_label_set_mnemonic_widget(GTK_LABEL(label), amount); info->price_currency_edit = gnc_currency_edit_new(); gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(info->price_currency_edit), gnc_default_currency()); gtk_widget_show (info->price_currency_edit); gtk_grid_attach (GTK_GRID(table), info->price_currency_edit, 1, 6, 1, 1); } /* Cash page Widgets */ { GtkWidget *box; GtkWidget *tree; GtkWidget *amount; GtkWidget *label; GtkWidget *scroll; GtkTreeSelection *selection; box = GTK_WIDGET(gtk_builder_get_object(builder, "cash_box")); amount = gnc_amount_edit_new (); g_signal_connect (amount, "changed", G_CALLBACK (gnc_stock_split_cash_valid_cb), info); gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (amount), TRUE); gtk_box_pack_start (GTK_BOX (box), amount, TRUE, TRUE, 0); info->cash_edit = amount; label = GTK_WIDGET(gtk_builder_get_object(builder, "cash_label")); gtk_label_set_mnemonic_widget(GTK_LABEL(label), amount); info->memo_entry = GTK_WIDGET(gtk_builder_get_object(builder, "memo_entry")); /* income tree */ tree = GTK_WIDGET(gnc_tree_view_account_new (FALSE)); info->income_tree = tree; gnc_tree_view_account_set_filter (GNC_TREE_VIEW_ACCOUNT (tree), gnc_stock_split_assistant_view_filter_income, NULL, /* user data */ NULL /* destroy callback */); gtk_widget_show (tree); gtk_tree_view_expand_all (GTK_TREE_VIEW(tree)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree)); gtk_tree_selection_unselect_all (selection); g_signal_connect (selection, "changed", G_CALLBACK (gnc_stock_split_cash_valid_cb), info); label = GTK_WIDGET(gtk_builder_get_object(builder, "income_label")); gtk_label_set_mnemonic_widget (GTK_LABEL(label), tree); scroll = GTK_WIDGET(gtk_builder_get_object(builder, "income_scroll")); gtk_container_add (GTK_CONTAINER (scroll), tree); /* asset tree */ tree = GTK_WIDGET(gnc_tree_view_account_new (FALSE)); info->asset_tree = tree; gnc_tree_view_account_set_filter (GNC_TREE_VIEW_ACCOUNT (tree), gnc_stock_split_assistant_view_filter_asset, NULL /* user data */, NULL /* destroy callback */); gtk_widget_show (tree); label = GTK_WIDGET(gtk_builder_get_object(builder, "asset_label")); gtk_label_set_mnemonic_widget (GTK_LABEL(label), tree); scroll = GTK_WIDGET(gtk_builder_get_object(builder, "asset_scroll")); gtk_container_add (GTK_CONTAINER (scroll), tree); gtk_tree_view_expand_all (GTK_TREE_VIEW(tree)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree)); gtk_tree_selection_unselect_all (selection); g_signal_connect (selection, "changed", G_CALLBACK (gnc_stock_split_cash_valid_cb), info); } g_signal_connect (G_OBJECT(window), "destroy", G_CALLBACK (gnc_stock_split_assistant_window_destroy_cb), info); gtk_builder_connect_signals(builder, info); g_object_unref(G_OBJECT(builder)); return window; }
/** Connect one dialog widget to the appropriate callback function for * its type. * * @internal * * @param name The name of the widget. * * @param widget A pointer to the widget. * * @param dialog A pointer to the dialog. */ static void gnc_prefs_connect_one (const gchar *name, GtkWidget *widget, gpointer user_data) { /* These tests must be ordered from more specific widget to less * specific widget. */ if (GTK_IS_FONT_BUTTON(widget)) { DEBUG(" %s - entry", name); gnc_prefs_connect_font_button(GTK_FONT_BUTTON(widget)); } else if (GTK_IS_RADIO_BUTTON(widget)) { DEBUG(" %s - radio button", name); gnc_prefs_connect_radio_button(GTK_RADIO_BUTTON(widget)); } else if (GTK_IS_CHECK_BUTTON(widget)) { DEBUG(" %s - check button", name); gnc_prefs_connect_check_button(GTK_CHECK_BUTTON(widget)); } else if (GTK_IS_SPIN_BUTTON(widget)) { DEBUG(" %s - spin button", name); gnc_prefs_connect_spin_button(GTK_SPIN_BUTTON(widget)); } else if (GTK_IS_COMBO_BOX(widget)) { DEBUG(" %s - combo box", name); gnc_prefs_connect_combo_box(GTK_COMBO_BOX(widget)); } else if (GTK_IS_ENTRY(widget)) { DEBUG(" %s - entry", name); gnc_prefs_connect_entry(GTK_ENTRY(widget)); } else if (GTK_IS_HBOX(widget)) { /* Test custom widgets are all children of a hbox */ GtkWidget *widget_child; GList* child = gtk_container_get_children(GTK_CONTAINER(widget)); widget_child = child->data; g_list_free(child); DEBUG(" %s - hbox", name); DEBUG("Hbox widget type is %s and name is %s", gtk_widget_get_name(GTK_WIDGET(widget_child)), name); if (GNC_IS_CURRENCY_EDIT(widget_child)) { DEBUG(" %s - currency_edit", name); gnc_prefs_connect_currency_edit(GNC_CURRENCY_EDIT(widget_child), name ); } else if (GNC_IS_PERIOD_SELECT(widget_child)) { DEBUG(" %s - period_Select", name); gnc_prefs_connect_period_select(GNC_PERIOD_SELECT(widget_child), name ); } else if (GNC_IS_DATE_EDIT(widget_child)) { DEBUG(" %s - date_edit", name); gnc_prefs_connect_date_edit(GNC_DATE_EDIT(widget_child), name ); } } else { DEBUG(" %s - unsupported %s", name, G_OBJECT_TYPE_NAME(G_OBJECT(widget))); } }
/******************************************************* * Create the Assistant *******************************************************/ static GtkWidget * csv_export_assistant_create (CsvExportInfo *info) { GtkBuilder *builder; GtkWidget *window; GtkWidget *box, *h_box; GtkWidget *button; GtkWidget *table, *hbox; time64 start_time, end_time; builder = gtk_builder_new(); gnc_builder_add_from_file (builder , "assistant-csv-export.glade", "CSV Export Assistant"); window = GTK_WIDGET(gtk_builder_get_object (builder, "CSV Export Assistant")); info->window = window; /* Set the assistant colors */ gnc_assistant_set_colors (GTK_ASSISTANT (info->window)); /* Load default settings */ load_settings (info); /* Start Page */ info->start_page = GTK_WIDGET(gtk_builder_get_object(builder, "start_page")); info->start_label = GTK_WIDGET(gtk_builder_get_object(builder, "start_label")); info->custom_entry = GTK_WIDGET(gtk_builder_get_object(builder, "custom_entry")); gtk_widget_set_sensitive (info->custom_entry, FALSE); /* Account Page */ info->account_page = GTK_WIDGET(gtk_builder_get_object(builder, "account_page")); if (info->export_type == XML_EXPORT_TREE) gtk_widget_destroy (info->account_page); else { GtkTreeView *tree_view; GtkTreeSelection *selection; GtkWidget *box, *label; info->csva.acct_info = GTK_WIDGET(gtk_builder_get_object (builder, "acct_info_vbox")); info->csva.num_acct_label = GTK_WIDGET(gtk_builder_get_object (builder, "num_accounts_label")); tree_view = gnc_tree_view_account_new (FALSE); info->csva.account_treeview = GTK_WIDGET(tree_view); selection = gtk_tree_view_get_selection (tree_view); gtk_tree_selection_set_mode (selection, GTK_SELECTION_EXTENDED); g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK(csv_export_account_changed_cb), info); gtk_widget_show (info->csva.account_treeview); box = GTK_WIDGET(gtk_builder_get_object (builder, "account_scroll")); gtk_container_add (GTK_CONTAINER(box), info->csva.account_treeview); label = GTK_WIDGET(gtk_builder_get_object (builder, "accounts_label")); gtk_label_set_mnemonic_widget (GTK_LABEL(label), GTK_WIDGET(tree_view)); /* select subaccounts button */ button = GTK_WIDGET(gtk_builder_get_object (builder, "select_subaccounts_button")); info->csva.select_button = button; g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK(csv_export_select_subaccounts_clicked_cb), info); g_signal_connect (G_OBJECT(info->csva.account_treeview), "cursor_changed", G_CALLBACK(csv_export_cursor_changed_cb), info); /* Set the date info */ button = GTK_WIDGET(gtk_builder_get_object (builder, "show_range")); /* Earliest and Latest in Book */ start_time = get_earliest_in_book (gnc_get_current_book()); end_time = gnc_time (NULL); info->csvd.start_time = start_time; info->csvd.end_time = end_time; gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button), FALSE); table = GTK_WIDGET(gtk_builder_get_object (builder, "select_range_table")); info->csvd.table = table; gtk_widget_set_sensitive (GTK_WIDGET(table), FALSE); info->csvd.start_date_choose = GTK_WIDGET(gtk_builder_get_object (builder, "start_date_choose")); info->csvd.start_date_today = GTK_WIDGET(gtk_builder_get_object (builder, "start_date_today")); info->csvd.end_date_choose = GTK_WIDGET(gtk_builder_get_object (builder, "end_date_choose")); info->csvd.end_date_today = GTK_WIDGET(gtk_builder_get_object (builder, "end_date_today")); /* Start date info */ info->csvd.start_date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE); hbox = GTK_WIDGET(gtk_builder_get_object (builder, "start_date_hbox")); gtk_box_pack_start (GTK_BOX(hbox), info->csvd.start_date, TRUE, TRUE, 0); gtk_widget_show (info->csvd.start_date); gnc_date_edit_set_time (GNC_DATE_EDIT(info->csvd.start_date), start_time); g_signal_connect (G_OBJECT(info->csvd.start_date), "date-changed", G_CALLBACK(csv_export_date_changed_cb), info); /* End date info */ info->csvd.end_date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE); hbox = GTK_WIDGET(gtk_builder_get_object (builder, "end_date_hbox")); gtk_box_pack_start (GTK_BOX(hbox), info->csvd.end_date, TRUE, TRUE, 0); gtk_widget_show (info->csvd.end_date); gnc_date_edit_set_time (GNC_DATE_EDIT(info->csvd.end_date), end_time); g_signal_connect (G_OBJECT (info->csvd.end_date), "date-changed", G_CALLBACK (csv_export_date_changed_cb), info); /* Load Accounts */ show_acct_type_accounts (info); update_accounts_tree (info); } /* File chooser Page */ info->file_page = GTK_WIDGET(gtk_builder_get_object(builder, "file_page")); info->file_chooser = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_SAVE); button = gtk_button_new_from_stock (GTK_STOCK_OK); gtk_widget_set_size_request (button, 100, -1); gtk_widget_show (button); h_box = gtk_hbox_new (TRUE, 0); gtk_box_pack_start(GTK_BOX(h_box), button, FALSE, FALSE, 0); gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(info->file_chooser), h_box); g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK(csv_export_file_chooser_confirm_cb), info); box = GTK_WIDGET(gtk_builder_get_object (builder, "file_page")); gtk_box_pack_start (GTK_BOX (box), info->file_chooser, TRUE, TRUE, 6); gtk_widget_show (info->file_chooser); /* Finish Page */ info->finish_label = GTK_WIDGET(gtk_builder_get_object (builder, "end_page")); /* Summary Page */ info->summary_label = GTK_WIDGET(gtk_builder_get_object (builder, "summary_page")); g_signal_connect (G_OBJECT(window), "destroy", G_CALLBACK(csv_export_assistant_destroy_cb), info); gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->window)); if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_SAVE_GEOMETRY)) { GObject *object = gtk_builder_get_object (builder, "paned"); gnc_prefs_bind (GNC_PREFS_GROUP, GNC_PREF_PANED_POS, object, "position"); } gtk_builder_connect_signals (builder, info); g_object_unref (G_OBJECT(builder)); return window; }
void gnc_stock_split_assistant_finish (GtkAssistant *assistant, gpointer user_data) { StockSplitInfo *info = user_data; GList *account_commits; GList *node; gnc_numeric amount; Transaction *trans; Account *account; Split *split; time64 date; account = info->acct; g_return_if_fail (account != NULL); amount = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (info->distribution_edit)); g_return_if_fail (!gnc_numeric_zero_p (amount)); gnc_suspend_gui_refresh (); trans = xaccMallocTransaction (gnc_get_current_book ()); xaccTransBeginEdit (trans); xaccTransSetCurrency (trans, gnc_default_currency ()); date = gnc_date_edit_get_date (GNC_DATE_EDIT (info->date_edit)); xaccTransSetDatePostedSecsNormalized (trans, date); { const char *description; description = gtk_entry_get_text (GTK_ENTRY (info->description_entry)); xaccTransSetDescription (trans, description); } split = xaccMallocSplit (gnc_get_current_book ()); xaccAccountBeginEdit (account); account_commits = g_list_prepend (NULL, account); xaccTransAppendSplit (trans, split); xaccAccountInsertSplit (account, split); xaccSplitSetAmount (split, amount); xaccSplitMakeStockSplit (split); /* Set split-action with gnc_set_num_action which is the same as * xaccSplitSetAction with these arguments */ /* Translators: This string has a disambiguation prefix */ gnc_set_num_action (NULL, split, NULL, Q_("Action Column|Split")); amount = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (info->price_edit)); if (gnc_numeric_positive_p (amount)) { QofBook *book; GNCPrice *price; GNCPriceDB *pdb; GNCCurrencyEdit *ce; Timespec ts; ce = GNC_CURRENCY_EDIT (info->price_currency_edit); ts.tv_sec = date; ts.tv_nsec = 0; price = gnc_price_create (gnc_get_current_book ()); gnc_price_begin_edit (price); gnc_price_set_commodity (price, xaccAccountGetCommodity (account)); gnc_price_set_currency (price, gnc_currency_edit_get_currency (ce)); gnc_price_set_time (price, ts); gnc_price_set_source (price, PRICE_SOURCE_STOCK_SPLIT); gnc_price_set_typestr (price, PRICE_TYPE_UNK); gnc_price_set_value (price, amount); gnc_price_commit_edit (price); book = gnc_get_current_book (); pdb = gnc_pricedb_get_db (book); if (!gnc_pricedb_add_price (pdb, price)) gnc_error_dialog (info->window, "%s", _("Error adding price.")); } amount = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (info->cash_edit)); if (gnc_numeric_positive_p (amount)) { const char *memo; memo = gtk_entry_get_text (GTK_ENTRY (info->memo_entry)); /* asset split */ account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT(info->asset_tree)); split = xaccMallocSplit (gnc_get_current_book ()); xaccAccountBeginEdit (account); account_commits = g_list_prepend (account_commits, account); xaccAccountInsertSplit (account, split); xaccTransAppendSplit (trans, split); xaccSplitSetAmount (split, amount); xaccSplitSetValue (split, amount); xaccSplitSetMemo (split, memo); /* income split */ account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT(info->income_tree)); split = xaccMallocSplit (gnc_get_current_book ()); xaccAccountBeginEdit (account); account_commits = g_list_prepend (account_commits, account); xaccAccountInsertSplit (account, split); xaccTransAppendSplit (trans, split); xaccSplitSetAmount (split, gnc_numeric_neg (amount)); xaccSplitSetValue (split, gnc_numeric_neg (amount)); xaccSplitSetMemo (split, memo); } xaccTransCommitEdit (trans); for (node = account_commits; node; node = node->next) xaccAccountCommitEdit (node->data); g_list_free (account_commits); gnc_resume_gui_refresh (); gnc_close_gui_component_by_data (ASSISTANT_STOCK_SPLIT_CM_CLASS, info); }
void gnc_ui_payment_window_set_date (PaymentWindow *pw, const GDate *date) { g_assert(pw); g_assert(date); gnc_date_edit_set_gdate (GNC_DATE_EDIT (pw->date_edit), date); }
const Recurrence * gnc_recurrence_get(GncRecurrence *gr) { guint mult; UIPeriodType period; PeriodType pt; GDate start; gboolean use_eom = FALSE, rel; mult = (guint) gtk_spin_button_get_value_as_int(gr->gsb_mult); gnc_date_edit_get_gdate(GNC_DATE_EDIT(gr->gde_start), &start); period = get_pt_ui(gr); switch (period) { case GNCR_DAY: pt = PERIOD_DAY; break; case GNCR_WEEK: pt = PERIOD_WEEK; break; case GNCR_MONTH: rel = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(gr->nth_weekday)); if (rel) { if (is_ambiguous_relative(&start)) { use_eom = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(gr->gcb_eom)); } else { GDateDay d; d = g_date_get_day(&start); use_eom = ((d - 1) / 7 == 4); } if (use_eom) pt = PERIOD_LAST_WEEKDAY; else pt = PERIOD_NTH_WEEKDAY; } else { if (g_date_is_last_of_month(&start) && (g_date_get_day(&start) < 31)) { // ambiguous, need to examine the checkbox use_eom = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(gr->gcb_eom)); } else { // if it's the last dom, use eom anyway because it's the 31st. use_eom = g_date_is_last_of_month(&start); } if (use_eom) pt = PERIOD_END_OF_MONTH; else pt = PERIOD_MONTH; } break; case GNCR_YEAR: pt = PERIOD_YEAR; break; default: pt = PERIOD_INVALID; } recurrenceSet(&gr->recurrence, mult, pt, &start, WEEKEND_ADJ_NONE); return &gr->recurrence; }
void gnc_payment_ok_cb (GtkWidget *widget, gpointer data) { PaymentWindow *pw = data; const char *text = NULL; if (!pw) return; /* The gnc_payment_window_check_payment function * ensures we have valid owner, post account, transfer account * and amount so we can proceed with the payment. * Note: make sure it's called before all entry points to this function ! */ gnc_suspend_gui_refresh (); { const char *memo, *num; Timespec date; gnc_numeric exch = gnc_numeric_create(1, 1); //default to "one to one" rate GList *selected_lots = NULL; GtkTreeSelection *selection; gboolean auto_pay; /* Obtain all our ancillary information */ memo = gtk_entry_get_text (GTK_ENTRY (pw->memo_entry)); num = gtk_entry_get_text (GTK_ENTRY (pw->num_entry)); date = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (pw->date_edit)); /* Obtain the list of selected lots (documents/payments) from the dialog */ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(pw->docs_list_tree_view)); gtk_tree_selection_selected_foreach (selection, get_selected_lots, &selected_lots); /* When the payment amount is 0, the selected documents cancel each other out * so no money is actually transferred. * For non-zero payments money will be transferred between the post account * and the transfer account. In that case if these two accounts don't have * the same currency the user is asked to enter the exchange rate. */ if (!gnc_numeric_zero_p (pw->amount_tot) && !gnc_commodity_equal(xaccAccountGetCommodity(pw->xfer_acct), xaccAccountGetCommodity(pw->post_acct))) { XferDialog* xfer; text = _("The transfer and post accounts are associated with different currencies. Please specify the conversion rate."); xfer = gnc_xfer_dialog(pw->dialog, pw->xfer_acct); gnc_info_dialog(pw->dialog, "%s", text); gnc_xfer_dialog_select_to_account(xfer, pw->post_acct); gnc_xfer_dialog_set_amount(xfer, pw->amount_tot); /* All we want is the exchange rate so prevent the user from thinking it makes sense to mess with other stuff */ gnc_xfer_dialog_set_from_show_button_active(xfer, FALSE); gnc_xfer_dialog_set_to_show_button_active(xfer, FALSE); gnc_xfer_dialog_hide_from_account_tree(xfer); gnc_xfer_dialog_hide_to_account_tree(xfer); gnc_xfer_dialog_is_exchange_dialog(xfer, &exch); gnc_xfer_dialog_run_until_done(xfer); } /* Perform the payment */ if (gncOwnerGetType (&(pw->owner)) == GNC_OWNER_CUSTOMER) auto_pay = gnc_prefs_get_bool (GNC_PREFS_GROUP_INVOICE, GNC_PREF_AUTO_PAY); else auto_pay = gnc_prefs_get_bool (GNC_PREFS_GROUP_BILL, GNC_PREF_AUTO_PAY); gncOwnerApplyPayment (&pw->owner, pw->pre_existing_txn, selected_lots, pw->post_acct, pw->xfer_acct, pw->amount_tot, exch, date, memo, num, auto_pay); } gnc_resume_gui_refresh (); /* Save the transfer account, xfer_acct */ gnc_payment_dialog_remember_account(pw, pw->xfer_acct); gnc_ui_payment_window_destroy (pw); }
gboolean gnc_ab_enter_daterange(GtkWidget *parent, const char *heading, Timespec *from_date, gboolean *last_retv_date, gboolean *first_possible_date, Timespec *to_date, gboolean *to_now) { GladeXML *xml; GtkWidget *dialog; GtkWidget *heading_label; GtkWidget *first_button; GtkWidget *last_retrieval_button; GtkWidget *now_button; DaterangeInfo info; gint result; xml = gnc_glade_xml_new("aqbanking.glade", "Date Range Dialog"); dialog = glade_xml_get_widget(xml, "Date Range Dialog"); g_object_set_data_full(G_OBJECT(dialog), "xml", xml, g_object_unref); glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, &info); if (parent) gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent)); heading_label = glade_xml_get_widget(xml, "heading_label"); first_button = glade_xml_get_widget(xml, "first_button"); last_retrieval_button = glade_xml_get_widget(xml, "last_retrieval_button"); info.enter_from_button = glade_xml_get_widget(xml, "enter_from_button"); now_button = glade_xml_get_widget(xml, "now_button"); info.enter_to_button = glade_xml_get_widget(xml, "enter_to_button"); info.from_dateedit = gnc_date_edit_new_ts(*from_date, FALSE, FALSE); gtk_container_add(GTK_CONTAINER(glade_xml_get_widget(xml, "enter_from_box")), info.from_dateedit); gtk_widget_show(info.from_dateedit); info.to_dateedit = gnc_date_edit_new_ts(*to_date, FALSE, FALSE); gtk_container_add(GTK_CONTAINER(glade_xml_get_widget(xml, "enter_to_box")), info.to_dateedit); gtk_widget_show(info.to_dateedit); if (*last_retv_date) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(last_retrieval_button), TRUE); } else { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(first_button), TRUE); gtk_widget_set_sensitive(last_retrieval_button, FALSE); } gtk_widget_set_sensitive(info.from_dateedit, FALSE); gtk_widget_set_sensitive(info.to_dateedit, FALSE); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); if (heading) gtk_label_set_text(GTK_LABEL(heading_label), heading); gtk_widget_show(dialog); result = gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_hide(dialog); if (result == GTK_RESPONSE_OK) { *from_date = gnc_date_edit_get_date_ts( GNC_DATE_EDIT(info.from_dateedit)); *last_retv_date = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(last_retrieval_button)); *first_possible_date = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(first_button)); *to_date = gnc_date_edit_get_date_ts( GNC_DATE_EDIT(info.to_dateedit)); *to_now = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(now_button)); } gtk_widget_destroy(dialog); return result == GTK_RESPONSE_OK; }
gboolean gnc_ab_enter_daterange(GtkWidget *parent, const char *heading, Timespec *from_date, gboolean *last_retv_date, gboolean *first_possible_date, Timespec *to_date, gboolean *to_now) { GtkBuilder *builder; GtkWidget *dialog; GtkWidget *heading_label; GtkWidget *first_button; GtkWidget *last_retrieval_button; GtkWidget *now_button; DaterangeInfo info; gint result; ENTER(""); builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-ab.glade", "aqbanking_date_range_dialog"); dialog = GTK_WIDGET(gtk_builder_get_object (builder, "aqbanking_date_range_dialog")); /* Connect the signals */ gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, &info ); if (parent) gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent)); heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label")); first_button = GTK_WIDGET(gtk_builder_get_object (builder, "first_button")); last_retrieval_button = GTK_WIDGET(gtk_builder_get_object (builder, "last_retrieval_button")); info.enter_from_button = GTK_WIDGET(gtk_builder_get_object (builder, "enter_from_button")); now_button = GTK_WIDGET(gtk_builder_get_object (builder, "now_button")); info.enter_to_button = GTK_WIDGET(gtk_builder_get_object (builder, "enter_to_button")); info.from_dateedit = gnc_date_edit_new_ts(*from_date, FALSE, FALSE); gtk_container_add(GTK_CONTAINER(gtk_builder_get_object (builder, "enter_from_box")), info.from_dateedit); gtk_widget_show(info.from_dateedit); info.to_dateedit = gnc_date_edit_new_ts(*to_date, FALSE, FALSE); gtk_container_add(GTK_CONTAINER(gtk_builder_get_object (builder, "enter_to_box")), info.to_dateedit); gtk_widget_show(info.to_dateedit); if (*last_retv_date) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(last_retrieval_button), TRUE); } else { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(first_button), TRUE); gtk_widget_set_sensitive(last_retrieval_button, FALSE); } gtk_widget_set_sensitive(info.from_dateedit, FALSE); gtk_widget_set_sensitive(info.to_dateedit, FALSE); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); if (heading) gtk_label_set_text(GTK_LABEL(heading_label), heading); gtk_widget_show(dialog); result = gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_hide(dialog); if (result == GTK_RESPONSE_OK) { *from_date = gnc_date_edit_get_date_ts( GNC_DATE_EDIT(info.from_dateedit)); *last_retv_date = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(last_retrieval_button)); *first_possible_date = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(first_button)); *to_date = gnc_date_edit_get_date_ts( GNC_DATE_EDIT(info.to_dateedit)); *to_now = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(now_button)); } g_object_unref(G_OBJECT(builder)); gtk_widget_destroy(dialog); LEAVE(""); return result == GTK_RESPONSE_OK; }
static gint sxftd_init( SXFromTransInfo *sxfti ) { GtkWidget *w; const char *transName; gint pos; GList *schedule = NULL; time_t start_tt; struct tm *tmpTm; GDate date, nextDate; if ( ! sxfti->sx ) { return -1; } if ( ! sxfti->trans ) { return -2; } if ( xaccTransIsOpen( sxfti->trans ) ) { return SXFTD_ERRNO_OPEN_XACTION; } sxfti_attach_callbacks(sxfti); /* Setup the example calendar and related data structures. */ { int num_marks = SXFTD_EXCAL_NUM_MONTHS * 31; w = GTK_WIDGET(glade_xml_get_widget( sxfti->gxml, SXFTD_EX_CAL_FRAME )); sxfti->dense_cal_model = gnc_dense_cal_store_new(num_marks); sxfti->example_cal = GNC_DENSE_CAL(gnc_dense_cal_new_with_model(GNC_DENSE_CAL_MODEL(sxfti->dense_cal_model))); g_object_ref_sink(sxfti->example_cal); g_assert(sxfti->example_cal); gnc_dense_cal_set_num_months( sxfti->example_cal, SXFTD_EXCAL_NUM_MONTHS ); gnc_dense_cal_set_months_per_col( sxfti->example_cal, SXFTD_EXCAL_MONTHS_PER_COL ); gtk_container_add( GTK_CONTAINER(w), GTK_WIDGET(sxfti->example_cal) ); } /* Setup the start and end dates as GNCDateEdits */ { GtkWidget *paramTable = glade_xml_get_widget( sxfti->gxml, SXFTD_PARAM_TABLE ); sxfti->startDateGDE = GNC_DATE_EDIT( gnc_date_edit_new( time( NULL ), FALSE, FALSE ) ); gtk_table_attach( GTK_TABLE(paramTable), GTK_WIDGET( sxfti->startDateGDE ), 1, 2, 2, 3, (GTK_EXPAND | GTK_FILL), GTK_FILL, 0, 0 ); g_signal_connect( sxfti->startDateGDE, "date-changed", G_CALLBACK( sxftd_update_excal_adapt ), sxfti ); } { GtkWidget *endDateBox = glade_xml_get_widget( sxfti->gxml, SXFTD_END_DATE_BOX ); sxfti->endDateGDE = GNC_DATE_EDIT( gnc_date_edit_new( time( NULL ), FALSE, FALSE ) ); gtk_box_pack_start( GTK_BOX( endDateBox ), GTK_WIDGET( sxfti->endDateGDE ), FALSE, TRUE, 0 ); g_signal_connect( sxfti->endDateGDE, "date-changed", G_CALLBACK( sxftd_update_excal_adapt ), sxfti ); } /* Get the name from the transaction, try that as the initial SX name. */ transName = xaccTransGetDescription( sxfti->trans ); xaccSchedXactionSetName( sxfti->sx, transName ); /* Setup the initial start date for user display/confirmation */ /* compute good initial date. */ start_tt = xaccTransGetDate( sxfti->trans ); g_date_set_time_t( &date, start_tt ); w = glade_xml_get_widget(sxfti->gxml, SXFTD_FREQ_COMBO_BOX); gtk_combo_box_set_active(GTK_COMBO_BOX(w), 0); g_signal_connect( w, "changed", G_CALLBACK(sxftd_freq_combo_changed), sxfti ); sxftd_update_schedule( sxfti, &date, &schedule); recurrenceListNextInstance(schedule, &date, &nextDate); recurrenceListFree(&schedule); tmpTm = g_new0( struct tm, 1 ); g_date_to_struct_tm( &nextDate, tmpTm ); start_tt = mktime( tmpTm ); g_free( tmpTm ); gnc_date_edit_set_time( sxfti->startDateGDE, start_tt ); w = glade_xml_get_widget( sxfti->gxml, SXFTD_NAME_ENTRY ); pos = 0; gtk_editable_insert_text( GTK_EDITABLE(w), transName, (strlen(transName) * sizeof(char)), &pos ); g_signal_connect( GTK_OBJECT(w), "destroy", G_CALLBACK(sxftd_destroy), sxfti ); sxftd_update_example_cal( sxfti ); return 0; }
gboolean gnc_dialog_date_close_parented (GtkWidget *parent, const char *message, const char *label_message, gboolean ok_is_default, /* Returned data ... */ Timespec *ts) { DialogDateClose *ddc; GtkWidget *date_box; GtkLabel *label; GtkBuilder *builder; gboolean retval; if (!message || !label_message || !ts) return FALSE; ddc = g_new0 (DialogDateClose, 1); ddc->ts = ts; builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-date-close.glade", "date_close_dialog"); ddc->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "date_close_dialog")); // Set the style context for this dialog so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(ddc->dialog), "GncDateCloseDialog"); date_box = GTK_WIDGET(gtk_builder_get_object (builder, "date_box")); ddc->date = gnc_date_edit_new (time(NULL), FALSE, FALSE); gtk_box_pack_start (GTK_BOX(date_box), ddc->date, TRUE, TRUE, 0); gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), *ts); if (parent) gtk_window_set_transient_for (GTK_WINDOW(ddc->dialog), GTK_WINDOW(parent)); /* Set the labels */ label = GTK_LABEL (gtk_builder_get_object (builder, "msg_label")); gtk_label_set_text (label, message); label = GTK_LABEL (gtk_builder_get_object (builder, "label")); gtk_label_set_text (label, label_message); /* Setup signals */ gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, ddc); gtk_widget_show_all (ddc->dialog); ddc->retval = FALSE; while (gtk_dialog_run (GTK_DIALOG (ddc->dialog)) == GTK_RESPONSE_OK) { /* If response is OK but flag is not set, try again */ if (ddc->retval) break; } g_object_unref(G_OBJECT(builder)); gtk_widget_destroy(ddc->dialog); retval = ddc->retval; g_list_free (ddc->acct_types); g_free (ddc); return retval; }
void gnc_frequency_init(GncFrequency *gf) { int i; GtkVBox* vb; GtkWidget* o; GtkAdjustment* adj; static const struct comboBoxTuple { char *name; void (*fn)(); } comboBoxes[] = { { "freq_combobox", freq_combo_changed }, { "semimonthly_first", semimonthly_sel_changed }, { "semimonthly_first_weekend", semimonthly_sel_changed }, { "semimonthly_second", semimonthly_sel_changed }, { "semimonthly_second_weekend", semimonthly_sel_changed }, { "monthly_day", monthly_sel_changed }, { "monthly_weekend", monthly_sel_changed }, { NULL, NULL } }; static const struct spinvalTuple { char *name; void (*fn)(); } spinVals[] = { { "daily_spin", spin_changed_helper }, { "weekly_spin", spin_changed_helper }, { "semimonthly_spin", spin_changed_helper }, { "monthly_spin", spin_changed_helper }, { NULL, NULL } }; gf->gxml = gnc_glade_xml_new("sched-xact.glade", "gncfreq_vbox"); o = glade_xml_get_widget(gf->gxml, "gncfreq_nb"); gf->nb = GTK_NOTEBOOK(o); o = glade_xml_get_widget(gf->gxml, "freq_combobox"); gf->freqComboBox = GTK_COMBO_BOX(o); gf->startDate = GNC_DATE_EDIT(gnc_date_edit_new(time(NULL), FALSE, FALSE)); /* Add the new widget to the table. */ { gint dont_expand_or_fill = 0; GtkWidget *table = glade_xml_get_widget(gf->gxml, "gncfreq_table"); gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(gf->startDate), 1, 2, 1, 2, dont_expand_or_fill, 0, 0, 0); } vb = GTK_VBOX(glade_xml_get_widget(gf->gxml, "gncfreq_vbox")); gf->vb = vb; gtk_container_add(GTK_CONTAINER(&gf->widget), GTK_WIDGET(gf->vb)); /* initialize the combo boxes */ for (i = 0; comboBoxes[i].name != NULL; i++) { o = glade_xml_get_widget(gf->gxml, comboBoxes[i].name); gtk_combo_box_set_active(GTK_COMBO_BOX(o), 0); if (comboBoxes[i].fn != NULL) { g_signal_connect(o, "changed", G_CALLBACK(comboBoxes[i].fn), gf); } } /* initialize the spin buttons */ for (i = 0; spinVals[i].name != NULL; i++) { if (spinVals[i].fn != NULL) { o = glade_xml_get_widget(gf->gxml, spinVals[i].name); adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(o)); g_signal_connect(adj, "value_changed", G_CALLBACK(spinVals[i].fn), gf); } } /* initialize the weekly::day-of-week checkbox-selection hooks */ for (i = 0; i < 7; i++) { o = glade_xml_get_widget(gf->gxml, CHECKBOX_NAMES[i]); g_signal_connect(o, "clicked", G_CALLBACK(weekly_days_changed), gf); } gtk_widget_show_all(GTK_WIDGET(&gf->widget)); /* respond to start date changes */ g_signal_connect(gf->startDate, "date_changed", G_CALLBACK(start_date_changed), gf); }
gboolean gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message, const char *date_label_message, const char *acct_label_message, gboolean ok_is_default, GList * acct_types, QofBook *book, /* Returned Data... */ Timespec *date, Account **acct) { DialogDateClose *ddc; GtkLabel *label; GtkWidget *date_box; GtkWidget *acct_box; GtkBuilder *builder; gboolean retval; if (!message || !date_label_message || !acct_label_message || !acct_types || !book || !date || !acct) return FALSE; ddc = g_new0 (DialogDateClose, 1); ddc->ts = date; ddc->book = book; ddc->acct_types = acct_types; ddc->acct = *acct; builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-date-close.glade", "date_account_dialog"); ddc->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "date_account_dialog")); // Set the style context for this dialog so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(ddc->dialog), "GncDateCloseDialog"); acct_box = GTK_WIDGET(gtk_builder_get_object (builder, "acct_hbox")); ddc->acct_combo = gnc_account_sel_new(); if (*acct) gnc_account_sel_set_account (GNC_ACCOUNT_SEL(ddc->acct_combo), *acct, FALSE); gtk_box_pack_start (GTK_BOX(acct_box), ddc->acct_combo, TRUE, TRUE, 0); date_box = GTK_WIDGET(gtk_builder_get_object (builder, "date_hbox")); ddc->date = gnc_date_edit_new (time(NULL), FALSE, FALSE); gtk_box_pack_start (GTK_BOX(date_box), ddc->date, TRUE, TRUE, 0); if (parent) gtk_window_set_transient_for (GTK_WINDOW(ddc->dialog), GTK_WINDOW(parent)); /* Set the labels */ label = GTK_LABEL (gtk_builder_get_object (builder, "top_msg_label")); gtk_label_set_text (label, message); label = GTK_LABEL (gtk_builder_get_object (builder, "date_label")); gtk_label_set_text (label, date_label_message); label = GTK_LABEL (gtk_builder_get_object (builder, "acct_label")); gtk_label_set_text (label, acct_label_message); /* Set the date widget */ gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), *date); /* Setup the account widget */ fill_in_acct_info (ddc, FALSE); /* Setup signals */ gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, ddc); gtk_widget_show_all (ddc->dialog); gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder, "postdate_label"))); gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder, "post_date_box"))); gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder, "memo_entry"))); gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder, "memo_label"))); ddc->retval = FALSE; while (gtk_dialog_run (GTK_DIALOG (ddc->dialog)) == GTK_RESPONSE_OK) { /* If response is OK but flag is not set, try again */ if (ddc->retval) break; } g_object_unref(G_OBJECT(builder)); gtk_widget_destroy(ddc->dialog); retval = ddc->retval; *acct = ddc->acct; g_free (ddc); return retval; }