コード例 #1
0
void
on_matcher_help_clicked (GtkButton *button, gpointer user_data)
{
    GNCImportMainMatcher *info = user_data;
    GtkBuilder *builder;
    GtkWidget *help_dialog, *box;

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer2");
    gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer3");
    gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer4");
    gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer5");
    gnc_builder_add_from_file (builder, "dialog-import.glade", "matcher_help");

    box = GTK_WIDGET(gtk_builder_get_object (builder, "red"));
    gtk_widget_modify_bg(box, GTK_STATE_NORMAL, &info->color_back_red);
    box = GTK_WIDGET(gtk_builder_get_object (builder, "yellow"));
    gtk_widget_modify_bg(box, GTK_STATE_NORMAL, &info->color_back_yellow);
    box = GTK_WIDGET(gtk_builder_get_object (builder, "green"));
    gtk_widget_modify_bg(box, GTK_STATE_NORMAL, &info->color_back_green);

    help_dialog = GTK_WIDGET(gtk_builder_get_object (builder, "matcher_help"));
    gtk_window_set_transient_for(GTK_WINDOW(help_dialog),
                                 GTK_WINDOW(info->dialog));

    /* Connect the signals */
    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, help_dialog);

    g_object_unref(G_OBJECT(builder));

    gtk_widget_show(help_dialog);
}
コード例 #2
0
ファイル: gnc-recurrence.c プロジェクト: 573/gnucash
static void
gnc_recurrence_init( GncRecurrence *gr )
{
    GtkVBox *vb;
    GtkHBox *hb;
    GtkWidget *w;
    GtkBuilder *builder;

    recurrenceSet(&gr->recurrence, 1, PERIOD_MONTH, NULL, WEEKEND_ADJ_NONE);

    /* Open up the builder file */
    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "gnc-recurrence.glade", "GCB_PeriodType_liststore");
    gnc_builder_add_from_file (builder, "gnc-recurrence.glade", "GSB_Mult_Adj");
    gnc_builder_add_from_file (builder, "gnc-recurrence.glade", "RecurrenceEntryVBox");

    vb = GTK_VBOX(gtk_builder_get_object (builder, "RecurrenceEntryVBox"));
    hb = GTK_HBOX(gtk_builder_get_object (builder, "Startdate_hbox"));
    w = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE);
    gr->gde_start = w;
    gtk_box_pack_start (GTK_BOX (hb), w, TRUE, TRUE, 0);
    gtk_widget_show (w);

    gtk_widget_set_no_show_all(GTK_WIDGET(gr->gde_start), TRUE);
    gr->gcb_period = GTK_COMBO_BOX(gtk_builder_get_object (builder, "GCB_PeriodType"));
    gr->gsb_mult = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, "GSB_Mult"));
    gr->gcb_eom = GTK_CHECK_BUTTON(gtk_builder_get_object (builder, "GCB_EndOfMonth"));
    gr->nth_weekday = GTK_CHECK_BUTTON(gtk_builder_get_object (builder, "GCB_NthWeekday"));
    gtk_widget_set_no_show_all(GTK_WIDGET(gr->gcb_eom), TRUE);
    gtk_widget_set_no_show_all(GTK_WIDGET(gr->nth_weekday), TRUE);

    gtk_container_add( GTK_CONTAINER(&gr->widget), GTK_WIDGET(vb) );

    gnc_recurrence_set(gr, &gr->recurrence);
    something_changed( GTK_WIDGET(gr), gr);

    /* Setup the signals */
    g_signal_connect( G_OBJECT(gr->gde_start), "date_changed",
                      G_CALLBACK(something_changed), gr );
    g_signal_connect( G_OBJECT(gr->gcb_period), "changed",
                      G_CALLBACK(something_changed), gr );
    g_signal_connect( G_OBJECT(gr->gsb_mult), "value-changed",
                      G_CALLBACK(something_changed), gr );
    g_signal_connect( G_OBJECT(gr->gcb_eom), "toggled",
                      G_CALLBACK(something_changed), gr );
    g_signal_connect( G_OBJECT(gr->nth_weekday), "toggled",
                      G_CALLBACK(something_changed), gr );

    gtk_widget_show_all( GTK_WIDGET(&gr->widget) );

    gtk_builder_connect_signals(builder, gr);
    g_object_unref(G_OBJECT(builder));
}
コード例 #3
0
static void
gnc_date_format_init (GNCDateFormat *gdf)
{
    GNCDateFormatPriv *priv;
    GtkBuilder *builder;
    GtkWidget *dialog, *table;

    g_return_if_fail(gdf);
    g_return_if_fail(GNC_IS_DATE_FORMAT(gdf));

    /* Open up the Glade and set the signals */
    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "gnc-date-format.glade", "format-liststore");
    gnc_builder_add_from_file (builder, "gnc-date-format.glade", "GNC Date Format");

    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, gdf);

    /* pull in all the child widgets */
    priv =  GNC_DATE_FORMAT_GET_PRIVATE(gdf);
    priv->label = GTK_WIDGET(gtk_builder_get_object (builder, "widget_label"));
    priv->format_combobox = GTK_WIDGET(gtk_builder_get_object (builder, "format_combobox"));

    priv->months_label = GTK_WIDGET(gtk_builder_get_object (builder, "months_label"));
    priv->months_number = GTK_WIDGET(gtk_builder_get_object (builder, "month_number_button"));
    priv->months_abbrev = GTK_WIDGET(gtk_builder_get_object (builder, "month_abbrev_button"));
    priv->months_name = GTK_WIDGET(gtk_builder_get_object (builder, "month_name_button"));

    priv->years_label = GTK_WIDGET(gtk_builder_get_object (builder, "years_label"));
    priv->years_button = GTK_WIDGET(gtk_builder_get_object (builder, "years_button"));

    priv->custom_label = GTK_WIDGET(gtk_builder_get_object (builder, "format_label"));
    priv->custom_entry = GTK_WIDGET(gtk_builder_get_object (builder, "format_entry"));

    priv->sample_label = GTK_WIDGET(gtk_builder_get_object (builder, "sample_label"));

    /* Set initial format to gnucash default */
    gnc_date_format_set_format(gdf, QOF_DATE_FORMAT_UNSET);

    /* pull in the dialog and table widgets and play the reconnect game */
    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "GNC Date Format"));

    table = GTK_WIDGET(gtk_builder_get_object (builder, "date_format_table"));
    g_object_ref(G_OBJECT(table));
    gtk_container_remove(GTK_CONTAINER(dialog), table);
    gtk_container_add(GTK_CONTAINER(gdf), table);
    g_object_unref(G_OBJECT(table));

    g_object_unref(G_OBJECT(builder));

    /* Destroy the now empty window */
    gtk_widget_destroy(dialog);
}
コード例 #4
0
/*********************
 * Create the dialog *
 ********************/
void
gnc_sx_create_from_trans( GtkWindow *parent, Transaction *trans )
{
#ifndef __MINGW32__
    int errno;
#endif
    SXFromTransInfo *sxfti = g_new0( SXFromTransInfo, 1);
    GtkBuilder *builder;
    GtkWidget *dialog;

    builder = gtk_builder_new();

    gnc_builder_add_from_file  (builder , "dialog-sx.glade", "freq_liststore");

    gnc_builder_add_from_file  (builder , "dialog-sx.glade", "sx_from_real_trans_dialog");
    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "sx_from_real_trans_dialog"));

    // Set the style context for this dialog so it can be easily manipulated with css
    gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncSxFromTransDialog");

    gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);

    sxfti->builder = builder;
    sxfti->dialog = dialog;
    sxfti->trans = trans;

    sxfti->sx = xaccSchedXactionMalloc(gnc_get_current_book ());

    if ( (errno = sxftd_init( sxfti )) < 0 )
    {
        if ( errno == SXFTD_ERRNO_OPEN_XACTION )
        {
            gnc_error_dialog (NULL, "%s",
                              _( "Cannot create a Scheduled Transaction "
                                 "from a Transaction currently "
                                 "being edited. Please Enter the "
                                 "Transaction before Scheduling." ) );
            sxftd_close( sxfti, TRUE );
            return;
        }
        else
        {
            g_error("sxftd_init: %d", errno);
        }
    }

    gtk_widget_show_all(GTK_WIDGET(sxfti->dialog));

    gtk_builder_connect_signals(builder, sxfti);
    g_object_unref(G_OBJECT(builder));
}
コード例 #5
0
ファイル: dialog-userpass.c プロジェクト: 573/gnucash
gboolean
gnc_get_username_password (GtkWidget *parent,
                           const char *heading,
                           const char *initial_username,
                           const char *initial_password,
                           char **username,
                           char **password)
{
    GtkWidget  *dialog;
    GtkWidget  *heading_label;
    GtkWidget  *username_entry;
    GtkWidget  *password_entry;
    GtkBuilder *builder;
    gint result;

    g_return_val_if_fail (username != NULL, FALSE);
    g_return_val_if_fail (password != NULL, FALSE);

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-userpass.glade", "Username Password Dialog");

    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Username Password Dialog"));

    if (parent)
        gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));

    heading_label  = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
    username_entry = GTK_WIDGET(gtk_builder_get_object (builder, "username_entry"));
    password_entry = GTK_WIDGET(gtk_builder_get_object (builder, "password_entry"));

    if (heading)
        gtk_label_set_text (GTK_LABEL (heading_label), heading);

    if (initial_username)
        gtk_entry_set_text (GTK_ENTRY (username_entry), initial_username);
    gtk_editable_select_region (GTK_EDITABLE (username_entry), 0, -1);

    if (initial_password)
        gtk_entry_set_text (GTK_ENTRY (password_entry), initial_password);

    result = gtk_dialog_run(GTK_DIALOG (dialog));
    gtk_widget_hide(dialog);

    if (result == GTK_RESPONSE_OK)
    {
        *username = gtk_editable_get_chars (GTK_EDITABLE (username_entry), 0, -1);
        *password = gtk_editable_get_chars (GTK_EDITABLE (password_entry), 0, -1);

        gtk_widget_destroy(dialog);
        return TRUE;
    }

    *username = NULL;
    *password = NULL;

    g_object_unref(G_OBJECT(builder));

    gtk_widget_destroy(dialog);
    return FALSE;
}
コード例 #6
0
ファイル: dialog-new-user.c プロジェクト: KhazMcdust/gnucash
void
gnc_ui_new_user_dialog (void)
{
    GtkWidget *dialog;
    GtkWidget *new_accounts_button;
    GtkWidget *import_qif_button;
    GtkWidget *tutorial_button;
    GtkBuilder  *builder;
    gint result;

    ENTER(" ");
    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-new-user.glade", "New User Dialog");

    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "New User Dialog"));

    new_accounts_button = GTK_WIDGET(gtk_builder_get_object (builder, "new_accounts_button"));
    import_qif_button = GTK_WIDGET(gtk_builder_get_object (builder, "import_qif_button"));
    tutorial_button = GTK_WIDGET(gtk_builder_get_object (builder, "tutorial_button"));

    /* Set the sensitivity of the qif-import button based on the availability
     * of the qif-import assistant.
     */
    gtk_widget_set_sensitive (import_qif_button, (qifImportAssistantFcn != NULL));

    result = gtk_dialog_run (GTK_DIALOG (dialog));
    switch (result)
    {
    case GTK_RESPONSE_CANCEL:
    case GTK_RESPONSE_DELETE_EVENT:
        gnc_ui_new_user_cancel_dialog ();
        break;
    case GTK_RESPONSE_OK:
        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (new_accounts_button)))
        {
            gnc_ui_hierarchy_assistant_with_callback(TRUE, after_hierarchy_assistant);
        }
        else if ((qifImportAssistantFcn != NULL)
                 && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (import_qif_button)))
        {
            qifImportAssistantFcn();
            gncp_new_user_finish ();
        }
        else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tutorial_button)))
        {
            gnc_gnome_help (HF_GUIDE, NULL);
            gncp_new_user_finish ();
        }
        break;
    default:
        g_print ("DEBUG: Response: %d", result);
        g_assert_not_reached ();
        break;
    }

    g_object_unref(G_OBJECT(builder));
    gtk_widget_destroy (dialog);
    LEAVE(" ");
}
コード例 #7
0
ファイル: dialog-totd.c プロジェクト: laguz/gnucash
void
gnc_totd_dialog (GtkWindow *parent, gboolean startup)
{
    TotdDialog *totd_dialog;

    GtkBuilder *builder;
    GtkWidget *dialog, *button;
    GtkTextView *textview;
    gboolean show_tips;

    totd_dialog = g_new0 (TotdDialog, 1);

    show_tips = gnc_prefs_get_bool(GNC_PREFS_GROUP, GNC_PREF_SHOW_TIPS);
    if (startup && !show_tips)
        return;

    if (tip_count == -1)
    {
        if (!gnc_totd_initialize())
            return;
        current_tip_number =  gnc_prefs_get_int(GNC_PREFS_GROUP, GNC_PREF_CURRENT_TIP);
    }

    if (gnc_forall_gui_components(DIALOG_TOTD_CM_CLASS, show_handler, NULL))
    {
        return;
    }

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-totd.glade", "totd_dialog");
    dialog  = GTK_WIDGET(gtk_builder_get_object (builder, "totd_dialog"));
    gtk_window_set_transient_for(GTK_WINDOW (dialog), parent);

    totd_dialog->dialog = dialog;

    ENTER("totd_dialog %p, dialog %p", totd_dialog, dialog);

    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, totd_dialog);

    button = GTK_WIDGET(gtk_builder_get_object (builder, "show_checkbutton"));
    totd_dialog->showcheck_button = button;

    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (button), show_tips);

    textview = GTK_TEXT_VIEW(gtk_builder_get_object (builder, "tip_textview"));
    totd_dialog->textview = textview;

    gnc_new_tip_number(totd_dialog, 1);

    gnc_restore_window_size(GNC_PREFS_GROUP, GTK_WINDOW(totd_dialog->dialog));
    gtk_widget_show(GTK_WIDGET (totd_dialog->dialog));

    gnc_register_gui_component(DIALOG_TOTD_CM_CLASS,
                               NULL, close_handler, totd_dialog);

    g_object_unref(G_OBJECT(builder));

    LEAVE("");
}
コード例 #8
0
static void
gnc_commodities_dialog_create (GtkWidget * parent, CommoditiesDialog *cd)
{
    GtkWidget *button;
    GtkWidget *scrolled_window;
    GtkBuilder *builder;
    GtkTreeView *view;
    GtkTreeSelection *selection;

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-commodities.glade", "securities_dialog");

    cd->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "securities_dialog"));
    cd->session = gnc_get_current_session();
    cd->book = qof_session_get_book(cd->session);
    cd->show_currencies = gnc_prefs_get_bool(GNC_PREFS_GROUP, GNC_PREF_INCL_ISO);

    // Set the style context for this dialog so it can be easily manipulated with css
    gnc_widget_set_style_context (GTK_WIDGET(cd->dialog), "GncCommoditiesDialog");

    gtk_builder_connect_signals(builder, cd);

    /* parent */
    if (parent != NULL)
        gtk_window_set_transient_for (GTK_WINDOW (cd->dialog), GTK_WINDOW (parent));

    /* buttons */
    cd->remove_button = GTK_WIDGET(gtk_builder_get_object (builder, "remove_button"));
    cd->edit_button = GTK_WIDGET(gtk_builder_get_object (builder, "edit_button"));

    /* commodity tree */

    scrolled_window = GTK_WIDGET(gtk_builder_get_object (builder, "commodity_list_window"));
    view = gnc_tree_view_commodity_new(cd->book,
                                       "state-section", STATE_SECTION,
                                       "show-column-menu", TRUE,
                                       NULL);
    cd->commodity_tree = GNC_TREE_VIEW_COMMODITY(view);
    gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET(view));
    gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(cd->commodity_tree), TRUE);
    gnc_tree_view_commodity_set_filter (cd->commodity_tree,
                                        gnc_commodities_dialog_filter_ns_func,
                                        gnc_commodities_dialog_filter_cm_func,
                                        cd, NULL);
    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
    g_signal_connect (G_OBJECT (selection), "changed",
                      G_CALLBACK (gnc_commodities_dialog_selection_changed), cd);

    g_signal_connect (G_OBJECT (cd->commodity_tree), "row-activated",
                      G_CALLBACK (row_activated_cb), cd);

    /* Show currency button */
    button = GTK_WIDGET(gtk_builder_get_object (builder, "show_currencies_button"));
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button), cd->show_currencies);

    g_object_unref(G_OBJECT(builder));
    gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(cd->dialog), GTK_WINDOW(parent));
}
コード例 #9
0
ファイル: dialog-sx-from-trans.c プロジェクト: Bob-IT/gnucash
/*********************
 * Create the dialog *
 ********************/
void
gnc_sx_create_from_trans( Transaction *trans )
{
    int errno;
    SXFromTransInfo *sxfti = g_new0( SXFromTransInfo, 1);
    GtkBuilder *builder;
    GtkWidget *dialog;

    builder = gtk_builder_new();

    gnc_builder_add_from_file  (builder , "dialog-sx.glade", "freq_liststore");

    gnc_builder_add_from_file  (builder , "dialog-sx.glade", "sx_from_real_trans");
    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "sx_from_real_trans"));

    sxfti->builder = builder;
    sxfti->dialog = dialog;
    sxfti->trans = trans;

    sxfti->sx = xaccSchedXactionMalloc(gnc_get_current_book ());

    if ( (errno = sxftd_init( sxfti )) < 0 )
    {
        if ( errno == SXFTD_ERRNO_OPEN_XACTION )
        {
            gnc_error_dialog( gnc_ui_get_toplevel(), "%s",
                              _( "Cannot create a Scheduled Transaction "
                                 "from a Transaction currently "
                                 "being edited. Please Enter the "
                                 "Transaction before Scheduling." ) );
            sxftd_close( sxfti, TRUE );
            return;
        }
        else
        {
            g_error("sxftd_init: %d", errno);
        }
    }

    gtk_widget_show_all(GTK_WIDGET(sxfti->dialog));

    gtk_builder_connect_signals(builder, sxfti);
    g_object_unref(G_OBJECT(builder));
}
コード例 #10
0
GNCImportMainMatcher * gnc_gen_trans_assist_new (GtkWidget *parent,
        const gchar* heading,
        gboolean all_from_same_account,
        gint match_date_hardlimit)
{
    GNCImportMainMatcher *info;
    GtkBuilder *builder;
    GtkWidget *heading_label;
    GtkWidget *box;
    gboolean show_update;

    info = g_new0 (GNCImportMainMatcher, 1);

    /* Initialize user Settings. */
    info->user_settings = gnc_import_Settings_new ();
    gnc_import_Settings_set_match_date_hardlimit (info->user_settings, match_date_hardlimit);

    /* load the interface */
    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-import.glade", "transaction_matcher_content");
    if (builder == NULL)
    {
        PERR("Error opening the glade builder interface");
    }
    /* Pack content into Assistant page widget */
    box = GTK_WIDGET(gtk_builder_get_object (builder, "transaction_matcher_content"));
    gtk_box_pack_start( GTK_BOX(parent), box, TRUE, TRUE, 6);

    /* Get the view */
    info->view = GTK_TREE_VIEW(gtk_builder_get_object (builder, "downloaded_view"));
    g_assert (info->view != NULL);

    show_update = gnc_import_Settings_get_action_update_enabled(info->user_settings);
    gnc_gen_trans_init_view(info, all_from_same_account, show_update);
    heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
    g_assert (heading_label != NULL);

    /*Initialise the colors */
    gdk_color_parse(COLOR_RED,    &info->color_back_red);
    gdk_color_parse(COLOR_YELLOW, &info->color_back_yellow);
    gdk_color_parse(COLOR_GREEN,  &info->color_back_green);

    if (heading)
        gtk_label_set_text (GTK_LABEL (heading_label), heading);

    info->transaction_processed_cb = NULL;

    /* Connect the signals */
    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, info);

    g_object_unref(G_OBJECT(builder));

    return info;
}
コード例 #11
0
ファイル: business-options-gnome.c プロジェクト: 573/gnucash
static GtkWidget *
create_taxtable_widget (GNCOption *option, GtkWidget *hbox)
{
    GtkWidget *widget;
    GtkBuilder *builder;

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "business-options-gnome.glade", "taxtable_store");
    gnc_builder_add_from_file (builder, "business-options-gnome.glade", "taxtable_menu");

    widget = GTK_WIDGET (gtk_builder_get_object (builder, "taxtable_menu"));
    gnc_taxtables_combo (GTK_COMBO_BOX(widget), gnc_get_current_book (), TRUE, NULL);
    gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);

    gnc_option_set_widget (option, widget);

    g_signal_connect (widget, "changed",
                      G_CALLBACK (gnc_option_changed_option_cb), option);

    g_object_unref(G_OBJECT(builder));
    return widget;
}
コード例 #12
0
ファイル: gnc-tree-view-owner.c プロジェクト: nishmu/gnucash
void
owner_filter_dialog_create(OwnerFilterDialog *fd, GncPluginPage *page)
{
    GtkWidget *dialog, *button;
    GtkBuilder *builder;
    gchar *title;

    ENTER("(fd %p, page %p)", fd, page);

    if (fd->dialog)
    {
        gtk_window_present(GTK_WINDOW(fd->dialog));
        LEAVE("existing dialog");
        return;
    }

    /* Create the dialog */
    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "gnc-tree-view-owner.glade", "Filter By");
    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Filter By"));
    fd->dialog = dialog;
    gtk_window_set_transient_for(GTK_WINDOW(dialog),
                                 GTK_WINDOW(GNC_PLUGIN_PAGE(page)->window));
    /* Translators: The %s is the name of the plugin page */
    title = g_strdup_printf(_("Filter %s by..."),
                            gnc_plugin_page_get_page_name(GNC_PLUGIN_PAGE(page)));
    gtk_window_set_title(GTK_WINDOW(dialog), title);
    g_free(title);

    /* Remember current state */
    fd->original_show_inactive = fd->show_inactive;
    fd->original_show_zero_total = fd->show_zero_total;

    /* Update the dialog widgets for the current state */
    button = GTK_WIDGET(gtk_builder_get_object (builder, "show_inactive"));
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button),
                                  fd->show_inactive);
    button = GTK_WIDGET(gtk_builder_get_object (builder, "show_zero"));
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button),
                                  fd->show_zero_total);

    /* Wire up the rest of the callbacks */
    gtk_builder_connect_signals (builder, fd);
    g_object_unref(G_OBJECT(builder));

    /* Show it */
    gtk_widget_show_all (dialog);
    LEAVE(" ");
}
コード例 #13
0
ファイル: dialog-price-edit-db.c プロジェクト: nishmu/gnucash
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(" ");
}
コード例 #14
0
/* Internal function that builds the dialog */
static CustomReportDialog *gnc_ui_custom_report_internal(GncMainWindow * window)
{

    GtkBuilder *builder;
    CustomReportDialog *crd;
    GtkTreeIter iter;
    GtkTreeModel *model;
    GtkWidget *no_report_notification;

    crd = g_new0(CustomReportDialog, 1);

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-custom-report.glade", "custom_report_dialog");

    crd->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "custom_report_dialog"));
    crd->reportview = GTK_WIDGET(gtk_builder_get_object (builder, "custom_report_list_view"));
    no_report_notification = GTK_WIDGET(gtk_builder_get_object (builder, "label2"));
    set_reports_view_and_model(crd);
    crd->window = window;

    gnc_restore_window_size (GNC_PREFS_GROUP_REPORT_SAVED_CONFIGS, GTK_WINDOW(crd->dialog));

    /* connect the signals */
    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, crd);

    gtk_widget_show_all(crd->dialog);

    /* check if there are currently saved reports available
     * by checking if there is a first element */
    model = gtk_tree_view_get_model (GTK_TREE_VIEW (crd->reportview));
    if (gtk_tree_model_get_iter_first (model, &iter))
    {
		/* saved reports available
		   -> hide the "no reports available" notification */
		gtk_widget_hide(no_report_notification);
	}
	else
	{
		/* hide the scrolled window of the report list */
		gtk_widget_hide(crd->reportview);
	}

    g_object_unref(G_OBJECT(builder));

    return crd;
}
コード例 #15
0
/********************************************************************\
 * autoClearWindow                                                  *
 *   opens up the window to auto-clear an account                   *
 *                                                                  *
 * Args:   parent  - the parent of this window                      *
 *         account - the account to auto-clear                      *
 * Return: autoClearData - the instance of this AutoClearWindow     *
\********************************************************************/
AutoClearWindow *
autoClearWindow (GtkWidget *parent, Account *account)
{
    GtkBox *box;
    GtkLabel *label;
    GtkBuilder *builder;
    AutoClearWindow *data;
    char *title;

    data = g_new0 (AutoClearWindow, 1);
    data->account = account;

    /* Create the dialog box */
    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "window-autoclear.glade", "auto_clear_start_dialog");
    data->window = GTK_WIDGET(gtk_builder_get_object (builder, "auto_clear_start_dialog"));
    title = gnc_autoclear_make_window_name (account);
    gtk_window_set_title(GTK_WINDOW(data->window), title);
    g_free (title);

    // Set the style context for this dialog so it can be easily manipulated with css
    gnc_widget_set_style_context (GTK_WIDGET(data->window), "GncAutoClearDialog");

    /* Add amount edit box */
    data->end_value = GNC_AMOUNT_EDIT(gnc_amount_edit_new());
    g_signal_connect(GTK_WIDGET(data->end_value), "activate",
                     G_CALLBACK(gnc_autoclear_window_ok_cb), data);

    box   = GTK_BOX(gtk_builder_get_object (builder, "end_value_box"));
    gtk_box_pack_start(box, GTK_WIDGET(data->end_value), TRUE, TRUE, 0);

    label = GTK_LABEL(gtk_builder_get_object (builder, "end_label"));
    gtk_label_set_mnemonic_widget(label, GTK_WIDGET(data->end_value));
    gtk_widget_grab_focus(GTK_WIDGET(data->end_value));

    data->status_label = GTK_LABEL(gtk_builder_get_object (builder, "status_label"));

    if (parent != NULL)
        gtk_window_set_transient_for (GTK_WINDOW (data->window), GTK_WINDOW (parent));

    gtk_builder_connect_signals(builder, data);
    g_object_unref(G_OBJECT(builder));

    return data;
}
コード例 #16
0
static void
gnc_ui_new_user_cancel_dialog (void)
{
    GtkWidget *dialog;
    GtkBuilder  *builder;
    gint result;
    gboolean keepshowing;

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-new-user.glade", "new_user_cancel_dialog");

    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "new_user_cancel_dialog"));

    result = gtk_dialog_run (GTK_DIALOG (dialog));
    keepshowing = (result == GTK_RESPONSE_YES);

    gnc_set_first_startup (keepshowing);
    gncp_new_user_finish ();

    g_object_unref(G_OBJECT(builder));
    gtk_widget_destroy(dialog);
}
コード例 #17
0
/********************************************************************\
 * init_match_picker_gui()
 * -- GUI initialization for the Match_Picker Dialog
\********************************************************************/
static void
init_match_picker_gui(GNCImportMatchPicker * matcher)
{
    GtkBuilder *builder;

    /* DEBUG("Begin..."); */

    /* Initialize user Settings. */
    matcher->user_settings = gnc_import_Settings_new ();

    /* load the interface */
    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-import.glade", "match_picker");
    g_return_if_fail (builder != NULL);

    matcher->transaction_matcher = GTK_WIDGET(gtk_builder_get_object (builder, "match_picker"));
    matcher->downloaded_view = (GtkTreeView *)GTK_WIDGET(gtk_builder_get_object (builder, "download_view"));
    matcher->match_view = (GtkTreeView *)GTK_WIDGET(gtk_builder_get_object (builder, "matched_view"));

    gnc_import_match_picker_init_downloaded_view(matcher);
    gnc_import_match_picker_init_match_view(matcher);

    /* DEBUG("User prefs:%s%d%s%d%s%d%s%d%s%d",
       " action_replace_enabled:",matcher->action_replace_enabled,
       ", action_skip_enabled:",matcher->action_skip_enabled,
       ", clear_threshold:",matcher->clear_threshold,
       ", add_threshold:",matcher->add_threshold,
       ", display_threshold:",matcher->display_threshold); */

    gnc_restore_window_size(GCONF_SECTION,
                            GTK_WINDOW (matcher->transaction_matcher));
    gtk_widget_show(matcher->transaction_matcher);

    g_object_unref(G_OBJECT(builder));

}/* end init_match_picker_gui */
コード例 #18
0
/***************************
 *                         *
 * Encodings dialog window *
 *                         *
 **************************/
void
gxi_edit_encodings_clicked_cb (GtkButton *button, GncXmlImportData *data)
{
    GtkBuilder *builder;
    GtkWidget *dialog;
    GtkListStore *list_store;
    GtkTreeStore *tree_store;
    GtkTreeIter iter, parent, *parent_ptr;
    GList *encodings_bak, *enc_iter;
    const gchar *encoding;
    system_encoding_type *system_enc;
    gpointer enc_ptr;
    gint i, j;

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "assistant-xml-encoding.glade", "Encodings Dialog");
    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Encodings Dialog"));
    data->encodings_dialog = dialog;

    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, data);

    gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (data->assistant));

    data->available_encs_view = GTK_TREE_VIEW (gtk_builder_get_object (builder, "available_encs_view"));

    data->custom_enc_entry = GTK_WIDGET(gtk_builder_get_object (builder, "custom_enc_entry"));

    /* set up selected encodings list */
    data->selected_encs_view = GTK_TREE_VIEW (gtk_builder_get_object (builder, "selected_encs_view"));
    list_store = gtk_list_store_new (ENC_NUM_COLS, G_TYPE_STRING, G_TYPE_POINTER);
    for (enc_iter = data->encodings; enc_iter; enc_iter = enc_iter->next)
    {
        encoding = g_quark_to_string (GPOINTER_TO_UINT (enc_iter->data));
        gtk_list_store_append (list_store, &iter);
        gtk_list_store_set (list_store, &iter, ENC_COL_STRING, encoding,
                            ENC_COL_QUARK, enc_iter->data, -1);
    }
    gtk_tree_view_insert_column_with_attributes (
        data->selected_encs_view, -1, NULL,
        gtk_cell_renderer_text_new (), "text", ENC_COL_STRING, NULL);
    gtk_tree_view_set_model (data->selected_encs_view,
                             GTK_TREE_MODEL (list_store));
    g_object_unref (list_store);

    /* set up system encodings list */
    data->available_encs_view = GTK_TREE_VIEW (gtk_builder_get_object (builder, "available_encs_view"));
    tree_store = gtk_tree_store_new (ENC_NUM_COLS, G_TYPE_STRING, G_TYPE_POINTER);
    for (i = 0, system_enc = system_encodings;
            i < n_system_encodings;
            i++, system_enc++)
    {
        if (i == 0)
        {
            /* first system encoding */
            parent_ptr = NULL;
        }
        else
        {
            parent_ptr = &iter;
            for (j = 0; j < system_enc->parent; j++)
                if (gtk_tree_model_iter_parent (GTK_TREE_MODEL (tree_store),
                                                &parent, &iter))
                {
                    /* go up one level */
                    iter = parent;
                }
                else
                {
                    /* no parent to toplevel element */
                    parent_ptr = NULL;
                }
        }
        if (system_enc->encoding)
            enc_ptr = GUINT_TO_POINTER (g_quark_from_string (system_enc->encoding));
        else
            enc_ptr = NULL;

        gtk_tree_store_append (tree_store, &iter, parent_ptr);
        gtk_tree_store_set (tree_store, &iter, ENC_COL_STRING,
                            gettext (system_enc->text), ENC_COL_QUARK, enc_ptr, -1);
    }
    gtk_tree_view_insert_column_with_attributes (
        data->available_encs_view, -1, NULL,
        gtk_cell_renderer_text_new (), "text", ENC_COL_STRING, NULL);
    gtk_tree_view_set_model (data->available_encs_view,
                             GTK_TREE_MODEL (tree_store));
    g_object_unref (tree_store);

    /* run the dialog */
    encodings_bak = g_list_copy (data->encodings);
    if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
    {
        g_list_free (encodings_bak);
        if (!g_list_find (data->encodings,
                          GUINT_TO_POINTER (data->default_encoding)))
        {
            /* choose top level encoding then */
            data->default_encoding = GPOINTER_TO_UINT (data->encodings->data);
        }

        /* update whole page */
        gxi_check_file (data);
        gxi_update_default_enc_combo (data);
        gxi_update_string_box (data);
        gxi_update_conversion_forward (data);
    }
    else
    {
        g_list_free (data->encodings);
        data->encodings = encodings_bak;
    }
    g_object_unref(G_OBJECT(builder));

    gtk_widget_destroy (dialog);
    data->encodings_dialog = NULL;
}
コード例 #19
0
/*******************************************************
 * Create the Assistant
 *******************************************************/
static GtkWidget *
csv_import_assistant_create (CsvImportInfo *info)
{
    GtkBuilder *builder;
    GtkWidget *window;
    GtkWidget *box, *h_box;
    GtkWidget *button;
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;

    builder = gtk_builder_new();
    gnc_builder_add_from_file  (builder , "assistant-csv-account-import.glade", "num_hrows_adj");
    gnc_builder_add_from_file  (builder , "assistant-csv-account-import.glade", "CSV Account Import Assistant");
    window = GTK_WIDGET(gtk_builder_get_object (builder, "CSV Account Import Assistant"));
    info->window = window;

    /* Set the assistant colors */
    gnc_assistant_set_colors (GTK_ASSISTANT (info->window));

    /* Load default settings */
    load_settings (info);

    /* Enable buttons on all page. */
    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "start_page")),
                                     TRUE);
    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "file_page")),
                                     FALSE);
    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "import_tree_page")),
                                     TRUE);
    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "end_page")),
                                     FALSE);
    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "summary_page")),
                                     TRUE);

    /* Start Page */

    /* File chooser Page */
    info->file_chooser = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_OPEN);
    g_signal_connect (G_OBJECT (info->file_chooser), "file-activated",
                      G_CALLBACK (csv_import_file_chooser_confirm_cb), info);
    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_import_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);

    /* Account Tree Page */
    info->header_row_spin = GTK_WIDGET(gtk_builder_get_object (builder, "num_hrows"));
    info->tree_view = GTK_WIDGET(gtk_builder_get_object (builder, "treeview"));

    info->regexp = g_string_new ( "^(?<type>[^;]*);(?<full_name>[^;]*);(?<name>[^;]*);(?<code>[^;]*);?(?<description>[^;]*);?(?<color>[^;]*);?(?<notes>[^;]*);?(?<commoditym>[^;]*);?(?<commodityn>[^;]*);?(?<hidden>[^;]*);?(?<tax>[^;]*);?(?<place_holder>[^;]*)$");

    /* create model and bind to view */
    info->store = gtk_list_store_new (N_COLUMNS,
                                      G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
                                      G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
    gtk_tree_view_set_model( GTK_TREE_VIEW(info->tree_view), GTK_TREE_MODEL(info->store) );
#define CREATE_COLUMN(description,column_id) \
  renderer = gtk_cell_renderer_text_new (); \
  column = gtk_tree_view_column_new_with_attributes (mnemonic_escape(_(description)), renderer, "text", column_id, NULL); \
  gtk_tree_view_column_add_attribute(column, renderer, "background", ROW_COLOR); \
  gtk_tree_view_column_set_resizable (column, TRUE); \
  gtk_tree_view_append_column (GTK_TREE_VIEW (info->tree_view), column);
    CREATE_COLUMN ("type", TYPE);
    CREATE_COLUMN ("full_name", FULL_NAME);
    CREATE_COLUMN ("name", NAME);
    CREATE_COLUMN ("code", CODE);
    CREATE_COLUMN ("description", DESCRIPTION);
    CREATE_COLUMN ("color", COLOR);
    CREATE_COLUMN ("notes", NOTES);
    CREATE_COLUMN ("commoditym", COMMODITYM);
    CREATE_COLUMN ("commodityn", COMMODITYN);
    CREATE_COLUMN ("hidden", HIDDEN);
    CREATE_COLUMN ("tax", TAX);
    CREATE_COLUMN ("place_holder", PLACE_HOLDER);

    /* 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_label"));
    info->summary_error_view = GTK_WIDGET(gtk_builder_get_object(builder, "summary_error_view"));

    g_signal_connect (G_OBJECT(window), "destroy",
                      G_CALLBACK (csv_import_assistant_destroy_cb), info);

    gnc_restore_window_size (GCONF_SECTION, GTK_WINDOW(info->window));

    gtk_builder_connect_signals(builder, info);
    g_object_unref(G_OBJECT(builder));
    return window;
}
コード例 #20
0
ファイル: dialog-preferences.c プロジェクト: 814ckf0x/gnucash
/** At dialog creation time, this function will be called once per
 *  adds-in.  It performs the work of adding the page into the main
 *  dialog.  It handles both the case of a full page being added to
 *  the dialog, and a partial page being added.
 *
 *  @internal
 *
 *  @param data A pointer to an addition data structure.
 *
 *  @param user_data A pointer to the dialog.
 */
static void
gnc_preferences_build_page (gpointer data,
                            gpointer user_data)
{
    GtkBuilder *builder;
    GtkWidget *dialog, *existing_content, *new_content, *label;
    GtkNotebook *notebook;
    addition *add_in;
    struct copy_data copydata;
    gint rows, cols;
    gchar **widgetname;
    gint i;

    ENTER("add_in %p, dialog %p", data, user_data);
    add_in = (addition *)data;
    dialog = user_data;

    DEBUG("Opening %s to get %s", add_in->filename, add_in->widgetname);
    builder = gtk_builder_new();

    /* Adjustments etc... must come before dialog information */
    widgetname = g_strsplit(add_in->widgetname, ",", -1);

    for (i = 0; widgetname[i]; i++)
    {
        DEBUG("Opening %s to get content %s", add_in->filename, widgetname[i]);
        gnc_builder_add_from_file (builder, add_in->filename, widgetname[i]);
    }

    DEBUG("Widget Content is %s", widgetname[i - 1]);
    new_content = GTK_WIDGET(gtk_builder_get_object (builder, widgetname[i - 1]));

    g_strfreev(widgetname);
    DEBUG("done");

    /* Add to the list of interesting widgets */
    gnc_prefs_build_widget_table(builder, dialog);

    /* Connect the signals in this glade file. The dialog is passed in
     * so the the callback can find "interesting" widgets from other
     * glade files if necessary (via the GPREFS_WIDGET_HASH hash table). */
    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, dialog);

    /* Prepare for recursion */
    notebook = g_object_get_data(G_OBJECT(dialog), NOTEBOOK);

    if (add_in->full_page)
    {
        label = gtk_label_new(add_in->tabname);
        gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
        gtk_notebook_append_page(notebook, new_content, label);
        g_object_unref(G_OBJECT(builder));
        LEAVE("appended page");
        return;
    }

    /* Copied tables must match the size of the main table */
    if (!GTK_IS_TABLE(new_content))
    {
        g_critical("The object name %s in file %s is not a GtkTable.  It cannot "
                   "be added to the preferences dialog.",
                   add_in->widgetname, add_in->filename);
        g_object_unref(G_OBJECT(builder));
        LEAVE("");
        return;
    }
    g_object_get(G_OBJECT(new_content), "n-columns", &cols, NULL);
    if (cols != 4)
    {
        g_critical("The table %s in file %s does not have four columns.  It cannot "
                   "be added to the preferences dialog.",
                   add_in->widgetname, add_in->filename);
        g_object_unref(G_OBJECT(builder));
        LEAVE("");
        return;
    }

    /* Does the page exist or must we create it */
    existing_content = gnc_prefs_find_page(notebook, add_in->tabname);

    if (!existing_content)
    {
        /* No existing content with this name.  Create a blank page */
        rows = 0;
        existing_content = gtk_table_new(0, 4, FALSE);
        gtk_container_set_border_width(GTK_CONTAINER(existing_content), 6);
        label = gtk_label_new(add_in->tabname);
        gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
        gtk_notebook_append_page(notebook, existing_content, label);
        gtk_widget_show_all(existing_content);
        DEBUG("created new page %s, appended it", add_in->tabname);
    }
    else
    {
        g_object_get(G_OBJECT(existing_content), "n-rows", &rows, NULL);
        DEBUG("found existing page %s", add_in->tabname);
    }

    /* Maybe add a spacer row */
    DEBUG("rows is %d", rows);
    if (rows > 0)
    {
        label = gtk_label_new("");
        gtk_widget_show(label);
        gtk_table_attach(GTK_TABLE(existing_content), label, 0, 1, rows, rows + 1,
                         GTK_FILL, GTK_FILL, 0, 0);
        rows++;
    }

    /* Now copy all the entries in the table */
    copydata.table_from = GTK_TABLE(new_content);
    copydata.table_to = GTK_TABLE(existing_content);
    copydata.row_offset = rows;
    gtk_container_foreach(GTK_CONTAINER(new_content), gnc_prefs_move_table_entry,
                          &copydata);

    g_object_ref_sink(new_content);
    g_object_unref(G_OBJECT(builder));

    LEAVE("added content to page");
}
コード例 #21
0
ファイル: dialog-preferences.c プロジェクト: 814ckf0x/gnucash
/** Create the preferences dialog.  This function first reads the
 *  dialog-preferences.glade file to obtain the content and then
 *  the dialog is created with a set of common preferences.  It then
 *  runs the list of add-ins, calling a helper function to add each full/partial
 *  page to this dialog, Finally it builds the "interesting widgets"
 *  table that is used for connecting the widgets up to callback functions.
 *
 *  @internal
 *
 *  @return A pointer to the newly created dialog.
 */
static GtkWidget *
gnc_preferences_dialog_create(void)
{
    GtkBuilder *builder;
    GtkWidget *dialog, *notebook, *label, *image;
    GtkWidget *box, *date, *period, *currency;
    GHashTable *prefs_table;
    GDate* gdate = NULL;
    gchar buf[128];
    GtkListStore *store;
    GtkTreePath *path;
    GtkTreeIter iter;
    gnc_commodity *locale_currency;
    const gchar *currency_name;
    QofBook *book;
    KvpFrame *book_frame;
    gint64 month, day;
    GDate fy_end;
    gboolean date_is_valid = FALSE;

    ENTER("");
    DEBUG("Opening dialog-preferences.glade:");
    builder = gtk_builder_new();

    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "auto_decimal_places_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "autosave_interval_minutes_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "save_on_close_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "date_backmonth_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "max_transactions_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "key_length_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "new_search_limit_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "retain_days_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "tab_width_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "date_formats");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "GnuCash Preferences");

    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "GnuCash Preferences"));

#ifndef REGISTER2_ENABLED
    /* Hide preferences that are related to register2 */
    box = GTK_WIDGET (gtk_builder_get_object (builder, "label14"));
    gtk_widget_hide (box);
    box = GTK_WIDGET (gtk_builder_get_object (builder, "pref/general.register/key-length"));
    gtk_widget_hide (box);
    box = GTK_WIDGET (gtk_builder_get_object (builder, "pref/general.register/show-extra-dates"));
    gtk_widget_hide (box);
    box = GTK_WIDGET (gtk_builder_get_object (builder, "pref/general.register/show-calendar-buttons"));
    gtk_widget_hide (box);
    box = GTK_WIDGET (gtk_builder_get_object (builder, "pref/general.register/selection-to-blank-on-expand"));
    gtk_widget_hide (box);
    box = GTK_WIDGET (gtk_builder_get_object (builder, "pref/general.register/show-extra-dates-on-selection"));
    gtk_widget_hide (box);
#endif

    label = GTK_WIDGET(gtk_builder_get_object (builder, "sample_account"));
    g_object_set_data(G_OBJECT(dialog), "sample_account", label);

    image = GTK_WIDGET(gtk_builder_get_object (builder, "separator_error"));
    g_object_set_data(G_OBJECT(dialog), "separator_error", image);

    DEBUG("autoconnect");
    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, dialog);

    DEBUG("done");

    notebook = GTK_WIDGET(gtk_builder_get_object (builder, "notebook1"));
    prefs_table = g_hash_table_new(g_str_hash, g_str_equal);
    g_object_set_data(G_OBJECT(dialog), NOTEBOOK, notebook);
    g_object_set_data_full(G_OBJECT(dialog), PREFS_WIDGET_HASH,
                           prefs_table, (GDestroyNotify)g_hash_table_destroy);


    book = gnc_get_current_book();
    g_date_clear (&fy_end, 1);
    qof_instance_get (QOF_INSTANCE (book),
		      "fy-end", &fy_end,
		      NULL);
    box = GTK_WIDGET(gtk_builder_get_object (builder,
                     "pref/" GNC_PREFS_GROUP_ACCT_SUMMARY "/" GNC_PREF_START_PERIOD));
    period = gnc_period_select_new(TRUE);
    gtk_widget_show (period);
    gtk_box_pack_start (GTK_BOX (box), period, TRUE, TRUE, 0);
    if (date_is_valid)
        gnc_period_select_set_fy_end(GNC_PERIOD_SELECT (period), &fy_end);

    box = GTK_WIDGET(gtk_builder_get_object (builder,
                     "pref/" GNC_PREFS_GROUP_ACCT_SUMMARY "/" GNC_PREF_END_PERIOD));
    period = gnc_period_select_new(FALSE);
    gtk_widget_show (period);
    gtk_box_pack_start (GTK_BOX (box), period, TRUE, TRUE, 0);
    if (date_is_valid)
        gnc_period_select_set_fy_end(GNC_PERIOD_SELECT (period), &fy_end);

    box = GTK_WIDGET(gtk_builder_get_object (builder,
                     "pref/" GNC_PREFS_GROUP_ACCT_SUMMARY "/" GNC_PREF_START_DATE));
    date = gnc_date_edit_new(gnc_time (NULL), FALSE, FALSE);
    gtk_widget_show (date);
    gtk_box_pack_start (GTK_BOX (box), date, TRUE, TRUE, 0);

    box = GTK_WIDGET(gtk_builder_get_object (builder,
                     "pref/" GNC_PREFS_GROUP_ACCT_SUMMARY "/" GNC_PREF_END_DATE));
    date = gnc_date_edit_new(gnc_time (NULL), FALSE, FALSE);
    gtk_widget_show (date);
    gtk_box_pack_start (GTK_BOX (box), date, TRUE, TRUE, 0);

    box = GTK_WIDGET(gtk_builder_get_object (builder,
                     "pref/" GNC_PREFS_GROUP_GENERAL "/" GNC_PREF_CURRENCY_OTHER));
    currency = gnc_currency_edit_new();
    gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(currency), gnc_default_currency());
    gtk_widget_show (currency);
    gtk_box_pack_start(GTK_BOX (box), currency, TRUE, TRUE, 0);

    box = GTK_WIDGET(gtk_builder_get_object (builder,
                     "pref/" GNC_PREFS_GROUP_GENERAL_REPORT "/" GNC_PREF_CURRENCY_OTHER));
    currency = gnc_currency_edit_new();
    gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(currency), gnc_default_currency());
    gtk_widget_show (currency);
    gtk_box_pack_start(GTK_BOX (box), currency, TRUE, TRUE, 0);


    /* Add to the list of interesting widgets */
    gnc_prefs_build_widget_table(builder, dialog);

    g_slist_foreach(add_ins, gnc_preferences_build_page, dialog);

    /* Sort tabs alphabetically */
    gnc_prefs_sort_pages(GTK_NOTEBOOK(notebook));
    gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);

    DEBUG("We have the following interesting widgets:");
    g_hash_table_foreach(prefs_table, (GHFunc)gnc_prefs_connect_one, dialog);
    DEBUG("Done with interesting widgets.");

    /* Other stuff */
    gdate = g_date_new_dmy(31, G_DATE_JULY, 2013);
    g_date_strftime(buf, sizeof(buf), "%x", gdate);
    store = GTK_LIST_STORE(gtk_builder_get_object (builder, "date_formats"));
    path = gtk_tree_path_new_from_indices (QOF_DATE_FORMAT_LOCALE, -1);
    if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path))
            gtk_list_store_set (store, &iter, 1, buf, -1);
    g_date_free(gdate);

    locale_currency = gnc_locale_default_currency ();
    currency_name = gnc_commodity_get_printname(locale_currency);
    label = GTK_WIDGET(gtk_builder_get_object (builder, "locale_currency"));
    gtk_label_set_label(GTK_LABEL(label), currency_name);
    label = GTK_WIDGET(gtk_builder_get_object (builder, "locale_currency2"));
    gtk_label_set_label(GTK_LABEL(label), currency_name);

    g_object_unref(G_OBJECT(builder));

    LEAVE("dialog %p", dialog);
    return dialog;
}
コード例 #22
0
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;

}
コード例 #23
0
ファイル: assistant-csv-export.c プロジェクト: fraga/gnucash
/*******************************************************
 * 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;
}
コード例 #24
0
static GtkWidget *
ap_assistant_create (AcctPeriodInfo *info)
{
    GtkBuilder *builder;
    GtkWidget *window;
    GtkWidget *box;

    builder = gtk_builder_new();
    gnc_builder_add_from_file  (builder , "assistant-acct-period.glade", "account_period_assistant");
    window = GTK_WIDGET(gtk_builder_get_object (builder, "account_period_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), "GncAssistAccountPeriod");

    /* Enable all pages except menu page. */
    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "start_page")),
                                     TRUE);
    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "book_page")),
                                     TRUE);
    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "finish_page")),
                                     TRUE);
    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "summary_page")),
                                     TRUE);

    info->close_status = -1;

    /* Find the date of the earliest transaction in the book.
     * Add a year minus a day as the first guess for book closing,
     * and use that to set up the freq spec widget. */
    info->earliest = get_earliest_in_book (gnc_get_current_book());
    info->earliest_str = qof_print_date(info->earliest);
    PINFO ("date of earliest transaction is %" G_GINT64_FORMAT " %s",
           info->earliest, gnc_ctime (&info->earliest));

    g_date_clear (&info->closing_date, 1);
    gnc_gdate_set_time64 (&info->closing_date, info->earliest);
    g_date_clear (&info->prev_closing_date, 1);
    info->prev_closing_date = info->closing_date;
    g_date_add_years (&info->closing_date, 1);

    {
        Recurrence *r = g_new0(Recurrence, 1);
        recurrenceSet(r, 1, PERIOD_MONTH, &info->closing_date, WEEKEND_ADJ_NONE);
        info->period = NULL;
        info->period = g_list_append(info->period, r);
    }

    info->period_menu = GNC_FREQUENCY(
                            gnc_frequency_new_from_recurrence(info->period, &info->closing_date));

    /* Change the text so that its more mainingful for this assistant */
    gnc_frequency_set_frequency_label_text(info->period_menu, _("Period:"));
    gnc_frequency_set_date_label_text(info->period_menu, _("Closing Date:"));

    /* Reparent to the correct location */

    box = GTK_WIDGET(gtk_builder_get_object(builder, "period_hbox"));
    gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (info->period_menu), TRUE, TRUE, 0);
    g_signal_connect (info->period_menu, "changed",
                      G_CALLBACK (ap_assistant_menu_changed_cb), info);

    /* Get handles to all of the other widgets we'll need */
    info->period_remarks = GTK_WIDGET(gtk_builder_get_object(builder, "remarks_label"));

    info->close_results = GTK_WIDGET(gtk_builder_get_object(builder, "results_label"));

    info->book_details = GTK_WIDGET(gtk_builder_get_object(builder, "book_label"));

    info->book_title = GTK_WIDGET(gtk_builder_get_object(builder, "book_title_entry"));

    info->book_notes = GTK_TEXT_VIEW(gtk_builder_get_object(builder, "book_notes_view"));

    info->apply_label = GTK_WIDGET(gtk_builder_get_object(builder, "finish_page"));

    info->summary = GTK_WIDGET(gtk_builder_get_object(builder, "summary_label"));

    g_signal_connect (G_OBJECT(window), "destroy",
                      G_CALLBACK (ap_assistant_destroy_cb), info);

    gtk_builder_connect_signals(builder, info);
    g_object_unref(G_OBJECT(builder));
    return window;
}
コード例 #25
0
GncSxSinceLastRunDialog*
gnc_ui_sx_since_last_run_dialog(GncSxInstanceModel *sx_instances, GList *auto_created_txn_guids)
{
    GncSxSinceLastRunDialog *dialog;
    GtkBuilder *builder;

    dialog = g_new0(GncSxSinceLastRunDialog, 1);

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-sx.glade", "since-last-run-dialog");

    dialog->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "since-last-run-dialog"));

    dialog->editing_model = gnc_sx_slr_tree_model_adapter_new(sx_instances);
    dialog->review_created_txns_toggle = GTK_TOGGLE_BUTTON(gtk_builder_get_object (builder, "review_txn_toggle"));

    dialog->created_txns = auto_created_txn_guids;

    {
        GtkCellRenderer *renderer;
        GtkTreeViewColumn *col;

        dialog->instance_view = GTK_TREE_VIEW(gtk_builder_get_object (builder, "instance_view"));
        gtk_tree_view_set_model(dialog->instance_view, GTK_TREE_MODEL(dialog->editing_model));

        renderer = gtk_cell_renderer_text_new();
        col = gtk_tree_view_column_new_with_attributes(_("Transaction"), renderer,
                "text", SLR_MODEL_COL_NAME,
                NULL);
        gtk_tree_view_append_column(dialog->instance_view, col);

        renderer = gtk_cell_renderer_combo_new();
        g_object_set(G_OBJECT(renderer),
                     "model", gnc_sx_get_slr_state_model(),
                     "text-column", 0,
                     "has-entry", FALSE,
                     "editable", TRUE,
                     NULL);
        g_signal_connect(G_OBJECT(renderer),
                         "edited",
                         G_CALLBACK(instance_state_changed_cb),
                         dialog);
        col = gtk_tree_view_column_new_with_attributes(_("Status"), renderer,
                "text", SLR_MODEL_COL_INSTANCE_STATE,
                "visible", SLR_MODEL_COL_INSTANCE_VISIBILITY,
                // you might think only "sensitive" is required to
                // control the ability of the combo box to select
                // a new state, but you'd be wrong.
                "editable", SLR_MODEL_COL_INSTANCE_STATE_SENSITIVITY,
                "sensitive", SLR_MODEL_COL_INSTANCE_STATE_SENSITIVITY,
                NULL);
        gtk_tree_view_append_column(dialog->instance_view, col);

        renderer = gtk_cell_renderer_text_new();
        g_object_set(G_OBJECT(renderer),
                     "editable", TRUE,
                     NULL);
        g_signal_connect(G_OBJECT(renderer),
                         "edited",
                         G_CALLBACK(variable_value_changed_cb),
                         dialog);
        col = gtk_tree_view_column_new_with_attributes(_("Value"), renderer,
                "text", SLR_MODEL_COL_VARAIBLE_VALUE,
                "visible", SLR_MODEL_COL_VARIABLE_VISIBILITY,
                NULL);
        gtk_tree_view_append_column(dialog->instance_view, col);

        gtk_tree_view_expand_all(dialog->instance_view);
    }

    g_signal_connect(G_OBJECT(dialog->dialog), "response", G_CALLBACK(dialog_response_cb), dialog);
    g_signal_connect(G_OBJECT(dialog->dialog), "destroy", G_CALLBACK(dialog_destroy_cb), dialog);

    gnc_restore_window_size(GNC_PREFS_GROUP_STARTUP, GTK_WINDOW(dialog->dialog));

    dialog->component_id = gnc_register_gui_component
                           (DIALOG_SX_SINCE_LAST_RUN_CM_CLASS, NULL, close_handler, dialog);
    gnc_gui_component_set_session(dialog->component_id,
                                  gnc_get_current_session());

    gtk_widget_show_all(dialog->dialog);

    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, dialog);

    g_object_unref(G_OBJECT(builder));

    return dialog;
}
コード例 #26
0
static CustomerWindow *
gnc_customer_new_window (QofBook *bookp, GncCustomer *cust)
{
    CustomerWindow *cw;
    GtkBuilder *builder;
    GtkWidget *hbox, *edit;
    gnc_commodity *currency;
    GNCPrintAmountInfo print_info;

    /*
     * Find an existing window for this customer.  If found, bring it to
     * the front.
     */
    if (cust)
    {
        GncGUID customer_guid;

        customer_guid = *gncCustomerGetGUID(cust);
        cw = gnc_find_first_gui_component (DIALOG_EDIT_CUSTOMER_CM_CLASS,
                                           find_handler, &customer_guid);
        if (cw)
        {
            gtk_window_present (GTK_WINDOW(cw->dialog));
            return(cw);
        }
    }

    /* Find the default currency */
    if (cust)
        currency = gncCustomerGetCurrency (cust);
    else
        currency = gnc_default_currency ();

    /*
     * No existing customer window found.  Build a new one.
     */
    cw = g_new0 (CustomerWindow, 1);

    cw->book = bookp;

    /* Find the dialog */
    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-customer.glade", "terms_store");
    gnc_builder_add_from_file (builder, "dialog-customer.glade", "tax_included_store");
    gnc_builder_add_from_file (builder, "dialog-customer.glade", "taxtable_store");
    gnc_builder_add_from_file (builder, "dialog-customer.glade", "Customer Dialog");
    cw->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "Customer Dialog"));

    g_object_set_data (G_OBJECT (cw->dialog), "dialog_info", cw);

    /* Get entry points */
    cw->id_entry = GTK_WIDGET (gtk_builder_get_object (builder, "id_entry"));
    cw->company_entry = GTK_WIDGET (gtk_builder_get_object (builder, "company_entry"));

    cw->name_entry = GTK_WIDGET (gtk_builder_get_object (builder, "name_entry"));
    cw->addr1_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr1_entry"));
    cw->addr2_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr2_entry"));
    cw->addr3_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr3_entry"));
    cw->addr4_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr4_entry"));
    cw->phone_entry = GTK_WIDGET (gtk_builder_get_object (builder, "phone_entry"));
    cw->fax_entry = GTK_WIDGET (gtk_builder_get_object (builder, "fax_entry"));
    cw->email_entry = GTK_WIDGET (gtk_builder_get_object (builder, "email_entry"));

    cw->shipname_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipname_entry"));
    cw->shipaddr1_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipaddr1_entry"));
    cw->shipaddr2_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipaddr2_entry"));
    cw->shipaddr3_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipaddr3_entry"));
    cw->shipaddr4_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipaddr4_entry"));
    cw->shipphone_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipphone_entry"));
    cw->shipfax_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipfax_entry"));
    cw->shipemail_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipemail_entry"));

    cw->active_check = GTK_WIDGET (gtk_builder_get_object (builder, "active_check"));
    cw->taxincluded_menu = GTK_WIDGET (gtk_builder_get_object (builder, "tax_included_menu"));
    cw->notes_text = GTK_WIDGET (gtk_builder_get_object (builder, "notes_text"));

    cw->terms_menu = GTK_WIDGET (gtk_builder_get_object (builder, "terms_menu"));

    cw->taxtable_check = GTK_WIDGET (gtk_builder_get_object (builder, "taxtable_button"));
    cw->taxtable_menu = GTK_WIDGET (gtk_builder_get_object (builder, "taxtable_menu"));

    /* Currency */
    edit = gnc_currency_edit_new();
    gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(edit), currency);
    cw->currency_edit = edit;

    hbox = GTK_WIDGET (gtk_builder_get_object (builder, "currency_box"));
    gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);

    /* DISCOUNT: Percentage Value */
    edit = gnc_amount_edit_new();
    gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE);
    print_info = gnc_integral_print_info ();
    print_info.max_decimal_places = 5;
    gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info);
    gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit), 100000);
    cw->discount_amount = edit;
    gtk_widget_show (edit);

    hbox = GTK_WIDGET (gtk_builder_get_object (builder, "discount_box"));
    gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);

    /* CREDIT: Monetary Value */
    edit = gnc_amount_edit_new();
    print_info = gnc_commodity_print_info (currency, FALSE);
    gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE);
    gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info);
    gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit),
                                  gnc_commodity_get_fraction (currency));
    cw->credit_amount = edit;
    gtk_widget_show (edit);

    hbox = GTK_WIDGET (gtk_builder_get_object (builder, "credit_box"));
    gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);

    /* Setup signals */
    gtk_builder_connect_signals_full( builder,
                                      gnc_builder_connect_full_func,
                                      cw);

    /* Setup initial values */
    if (cust != NULL)
    {
        GtkTextBuffer* text_buffer;
        GncAddress *addr, *shipaddr;
        const char *string;

        cw->dialog_type = EDIT_CUSTOMER;
        cw->customer_guid = *gncCustomerGetGUID (cust);

        addr = gncCustomerGetAddr (cust);
        shipaddr = gncCustomerGetShipAddr (cust);

        gtk_entry_set_text (GTK_ENTRY (cw->id_entry), gncCustomerGetID (cust));
        gtk_entry_set_text (GTK_ENTRY (cw->company_entry), gncCustomerGetName (cust));

        /* Setup Address */
        gtk_entry_set_text (GTK_ENTRY (cw->name_entry), gncAddressGetName (addr));
        gtk_entry_set_text (GTK_ENTRY (cw->addr1_entry), gncAddressGetAddr1 (addr));
        gtk_entry_set_text (GTK_ENTRY (cw->addr2_entry), gncAddressGetAddr2 (addr));
        gtk_entry_set_text (GTK_ENTRY (cw->addr3_entry), gncAddressGetAddr3 (addr));
        gtk_entry_set_text (GTK_ENTRY (cw->addr4_entry), gncAddressGetAddr4 (addr));
        gtk_entry_set_text (GTK_ENTRY (cw->phone_entry), gncAddressGetPhone (addr));
        gtk_entry_set_text (GTK_ENTRY (cw->fax_entry), gncAddressGetFax (addr));
        gtk_entry_set_text (GTK_ENTRY (cw->email_entry), gncAddressGetEmail (addr));

        /* Setup Ship-to Address */
        gtk_entry_set_text (GTK_ENTRY (cw->shipname_entry), gncAddressGetName (shipaddr));
        gtk_entry_set_text (GTK_ENTRY (cw->shipaddr1_entry), gncAddressGetAddr1 (shipaddr));
        gtk_entry_set_text (GTK_ENTRY (cw->shipaddr2_entry), gncAddressGetAddr2 (shipaddr));
        gtk_entry_set_text (GTK_ENTRY (cw->shipaddr3_entry), gncAddressGetAddr3 (shipaddr));
        gtk_entry_set_text (GTK_ENTRY (cw->shipaddr4_entry), gncAddressGetAddr4 (shipaddr));
        gtk_entry_set_text (GTK_ENTRY (cw->shipphone_entry), gncAddressGetPhone (shipaddr));
        gtk_entry_set_text (GTK_ENTRY (cw->shipfax_entry), gncAddressGetFax (shipaddr));
        gtk_entry_set_text (GTK_ENTRY (cw->shipemail_entry), gncAddressGetEmail (shipaddr));

        /* Set toggle buttons */
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cw->active_check),
                                      gncCustomerGetActive (cust));

        string = gncCustomerGetNotes (cust);
        text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(cw->notes_text));
        gtk_text_buffer_set_text (text_buffer, string, -1);

        cw->component_id =
            gnc_register_gui_component (DIALOG_EDIT_CUSTOMER_CM_CLASS,
                                        gnc_customer_window_refresh_handler,
                                        gnc_customer_window_close_handler,
                                        cw);
        cw->terms = gncCustomerGetTerms (cust);

    }
    else
    {
        cust = gncCustomerCreate (bookp);
        cw->customer_guid = *gncCustomerGetGUID (cust);

        cw->dialog_type = NEW_CUSTOMER;
        cw->component_id =
            gnc_register_gui_component (DIALOG_NEW_CUSTOMER_CM_CLASS,
                                        gnc_customer_window_refresh_handler,
                                        gnc_customer_window_close_handler,
                                        cw);

        /* XXX: get the global-default terms */
        cw->terms = NULL;
    }

    /* I know that cust exists here -- either passed in or just created */

    cw->taxincluded = gncCustomerGetTaxIncluded (cust);
    gnc_taxincluded_combo (GTK_COMBO_BOX(cw->taxincluded_menu), cw->taxincluded);
    gnc_billterms_combo (GTK_COMBO_BOX(cw->terms_menu), bookp, TRUE, cw->terms);

    cw->taxtable = gncCustomerGetTaxTable (cust);
    gnc_taxtables_combo (GTK_COMBO_BOX(cw->taxtable_menu), bookp, TRUE, cw->taxtable);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cw->taxtable_check),
                                  gncCustomerGetTaxTableOverride (cust));
    gnc_customer_taxtable_check_cb (GTK_TOGGLE_BUTTON (cw->taxtable_check), cw);

    /* Set up the addr line quickfill */
    cw->addr2_quickfill = gnc_get_shared_address_addr2_quickfill(cw->book, ADDR_QUICKFILL);
    cw->addr3_quickfill = gnc_get_shared_address_addr3_quickfill(cw->book, ADDR_QUICKFILL);
    cw->addr4_quickfill = gnc_get_shared_address_addr4_quickfill(cw->book, ADDR_QUICKFILL);

    /* Set the Discount, and Credit amounts */
    gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (cw->discount_amount),
                                gncCustomerGetDiscount (cust));
    gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (cw->credit_amount),
                                gncCustomerGetCredit (cust));

    gnc_gui_component_watch_entity_type (cw->component_id,
                                         GNC_CUSTOMER_MODULE_NAME,
                                         QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);

    gtk_widget_show_all (cw->dialog);
    g_object_unref(G_OBJECT(builder));

    return cw;
}
コード例 #27
0
ファイル: dialog-account-picker.c プロジェクト: 573/gnucash
/****************************************************************
 * qif_account_picker_dialog
 *
 * Select an account from the ones that the engine knows about,
 * plus those that will be created by the QIF import.  If the
 * user clicks OK, map_entry is changed and TRUE is returned.
 * If the clicks Cancel instead, FALSE is returned. Modal.
 ****************************************************************/
gboolean
qif_account_picker_dialog(QIFImportWindow * qif_wind, SCM map_entry)
{
    QIFAccountPickerDialog * wind;
    SCM gnc_name     = scm_c_eval_string("qif-map-entry:gnc-name");
    SCM set_gnc_name = scm_c_eval_string("qif-map-entry:set-gnc-name!");
    SCM orig_acct    = scm_call_1(gnc_name, map_entry);
    int response;
    GtkBuilder *builder;
    GtkWidget *button;

    wind = g_new0(QIFAccountPickerDialog, 1);

    /* Save the map entry. */
    wind->map_entry = map_entry;
    scm_gc_protect_object(wind->map_entry);

    /* Set the initial account to be selected. */
    if (scm_is_string(orig_acct))
        wind->selected_name = gnc_scm_to_utf8_string (orig_acct);

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-account-picker.glade", "QIF Import Account Picker");

    /* Connect all the signals */
    gtk_builder_connect_signals (builder, wind);

    wind->dialog     = GTK_WIDGET(gtk_builder_get_object (builder, "QIF Import Account Picker"));
    wind->treeview   = GTK_TREE_VIEW(gtk_builder_get_object (builder, "account_tree"));
    wind->qif_wind   = qif_wind;

    {
        GtkTreeStore *store;
        GtkCellRenderer *renderer;
        GtkTreeViewColumn *column;
        GtkTreeSelection *selection;

        store = gtk_tree_store_new(NUM_ACCOUNT_COLS, G_TYPE_STRING, G_TYPE_STRING,
                                   G_TYPE_BOOLEAN);
        gtk_tree_view_set_model(wind->treeview, 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",
                 ACCOUNT_COL_NAME,
                 NULL);
        g_object_set(column, "expand", TRUE, NULL);
        gtk_tree_view_append_column(wind->treeview, column);

        renderer = gtk_cell_renderer_toggle_new();
        g_object_set(renderer, "activatable", FALSE, NULL);
        column = gtk_tree_view_column_new_with_attributes(_("New?"),
                 renderer,
                 "active",
                 ACCOUNT_COL_CHECK,
                 NULL);
        gtk_tree_view_append_column(wind->treeview, column);

        selection = gtk_tree_view_get_selection(wind->treeview);
        g_signal_connect(selection, "changed",
                         G_CALLBACK(gnc_ui_qif_account_picker_changed_cb), wind);
        g_signal_connect(wind->treeview, "row-activated",
                         G_CALLBACK(gnc_ui_qif_account_picker_row_activated_cb),
                         wind);
    }

    g_signal_connect_after(wind->dialog, "map",
                           G_CALLBACK(gnc_ui_qif_account_picker_map_cb),
                           wind);

    button =  GTK_WIDGET(gtk_builder_get_object (builder, "newbutton"));
    gtk_button_set_use_stock(GTK_BUTTON(button), TRUE);

    /* this is to get the checkmarks set up right.. it will get called
     * again after the window is mapped. */
    build_acct_tree(wind, wind->qif_wind);

    do
    {
        response = gtk_dialog_run(GTK_DIALOG(wind->dialog));
    }
    while (response == GNC_RESPONSE_NEW);
    gtk_widget_destroy(wind->dialog);
    g_object_unref(G_OBJECT(builder));

    scm_gc_unprotect_object(wind->map_entry);
    g_free(wind->selected_name);
    g_free(wind);

    if (response == GTK_RESPONSE_OK)
        return TRUE;

    /* Restore the original mapping. */
    scm_call_2(set_gnc_name, map_entry, orig_acct);

    return FALSE;
}
コード例 #28
0
ファイル: dialog-query-view.c プロジェクト: 573/gnucash
DialogQueryView *
gnc_dialog_query_view_new (GList *param_list, Query *q)
{
    GtkBuilder  *builder;
    DialogQueryView *dqv;
    GtkWidget *result_hbox, *close, *scrollWin, *frame, *but_hbox;
    GList *node;

    dqv = g_new0 (DialogQueryView, 1);
    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-query-view.glade", "Query View Dialog");

    /* Grab the dialog, save the dialog info */
    dqv->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Query View Dialog"));
    g_object_set_data (G_OBJECT (dqv->dialog), "dialog-info", dqv);

    /* grab the widgets */
    dqv->label = GTK_WIDGET(gtk_builder_get_object (builder, "dialog_label"));
    result_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "result_hbox"));
    close = GTK_WIDGET(gtk_builder_get_object (builder, "close_button"));

    /* build the query list */
    dqv->qview = gnc_query_view_new (param_list, q);

    frame = gtk_frame_new(NULL);

    scrollWin = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrollWin),
                                   GTK_POLICY_AUTOMATIC,
                                   GTK_POLICY_AUTOMATIC);
    gtk_container_set_border_width(GTK_CONTAINER(scrollWin), 5);

    gtk_container_add(GTK_CONTAINER(scrollWin), dqv->qview);
    gtk_container_add(GTK_CONTAINER(frame), scrollWin);

    gtk_box_pack_start (GTK_BOX (result_hbox), frame, TRUE, TRUE, 3);

    /* Create the button_box */
    dqv->button_box = gtk_vbox_new (FALSE, 2);
    gtk_box_pack_start (GTK_BOX (result_hbox), dqv->button_box, FALSE, FALSE, 3);

    /* connect the double-click signal of the qview */
    g_signal_connect (G_OBJECT (dqv->qview), "double_click_entry",
                      G_CALLBACK(gnc_dialog_query_view_double_click_entry), dqv);

    /* connect to the close button */
    g_signal_connect (G_OBJECT (close), "clicked",
                      G_CALLBACK (gnc_dialog_query_view_close), dqv);

    /* connect to the cleanup */
    g_signal_connect (G_OBJECT (dqv->dialog), "delete_event",
                      G_CALLBACK (gnc_dialog_query_view_delete_cb), dqv);

    /* register ourselves */
    dqv->component_id = gnc_register_gui_component ("GNC Dialog Query View",
                        gnc_dialog_query_view_refresh_handler,
                        close_handler, dqv);

    /* Build the book list */
    dqv_build_booklist (dqv, q);

    /* and register the books */
    for (node = dqv->books; node; node = node->next)
        gnc_gui_component_watch_entity (dqv->component_id, (GncGUID*)node->data,
                                        QOF_EVENT_DESTROY);

    g_object_unref(G_OBJECT(builder));

    return dqv;
}
コード例 #29
0
static GtkWidget *
gnc_create_hierarchy_assistant (gboolean use_defaults, GncHierarchyAssistantFinishedCallback when_completed)
{
    hierarchy_data *data;
    GtkWidget *dialog;
    GtkTreeView *tree_view;
    GtkWidget *box;
    GtkBuilder *builder;

    data = g_new0 (hierarchy_data, 1);

    /* Presumably this assistant is only used to create a new book but we check.
     * When gnucash is started with --nofile, there is initially no session (and
     * no book), but by the time we get here, one could have been created (for
     * example, if an empty account tree tab is opened, a session is created
     * which creates a new, but empty, book). */
    data->new_book = gnc_is_new_book();

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "assistant-hierarchy.glade", "Hierarchy Assistant");

    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Hierarchy Assistant"));
    data->dialog = dialog;

    /* If we have a callback, make this window stay on top */
    if (when_completed != NULL)
        gtk_window_set_keep_above (GTK_WINDOW(data->dialog), TRUE);

    gnc_assistant_set_colors (GTK_ASSISTANT (data->dialog));

    /* Enable buttons on first and last page. */
    gtk_assistant_set_page_complete (GTK_ASSISTANT (dialog),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "intro_page_label")),
                                     TRUE);
    gtk_assistant_set_page_complete (GTK_ASSISTANT (dialog),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "currency_book_option_page_vbox")),
                                     TRUE);
    gtk_assistant_set_page_complete (GTK_ASSISTANT (dialog),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "final_account_vbox")),
                                     TRUE);
    gtk_assistant_set_page_complete (GTK_ASSISTANT (dialog),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "finish_page_label")),
                                     TRUE);

    /* Currency Page */
    data->currency_selector = gnc_currency_edit_new();
    gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(data->currency_selector), gnc_default_currency());
    gtk_widget_show (data->currency_selector);
    box = GTK_WIDGET(gtk_builder_get_object (builder, "currency_chooser_hbox"));
    gtk_box_pack_start(GTK_BOX(box), data->currency_selector, TRUE, TRUE, 0);

    /* Categories Page */
    tree_view = GTK_TREE_VIEW(gtk_builder_get_object (builder, "account_categories_tree_view"));
    g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (tree_view)), "changed",
                      G_CALLBACK (categories_tree_selection_changed), data);
    gtk_tree_selection_set_mode (gtk_tree_view_get_selection (tree_view), GTK_SELECTION_SINGLE);
    data->categories_tree = tree_view;

    data->category_accounts_label = GTK_LABEL(gtk_builder_get_object (builder, "accounts_in_category_label"));
    data->category_accounts_container = GTK_WIDGET(gtk_builder_get_object (builder, "accounts_in_category"));
    data->category_description = GTK_TEXT_VIEW(gtk_builder_get_object (builder, "account_types_description"));
    data->account_list_added = FALSE;

    /* Book options page - only on new books */
    if (data->new_book)
        assistant_instert_book_options_page (data);

    /* Final Accounts Page */
    data->final_account_tree_container = GTK_WIDGET(gtk_builder_get_object (builder, "final_account_tree_box"));
    data->final_account_tree = NULL;

    data->balance_hash = g_hash_table_new(NULL, NULL);

    gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(data->dialog));

    g_signal_connect (G_OBJECT(dialog), "destroy",
                      G_CALLBACK (gnc_hierarchy_destroy_cb), data);

    gtk_builder_connect_signals(builder, data);
    g_object_unref(G_OBJECT(builder));

    data->when_completed = when_completed;
    data->use_defaults = use_defaults;
    return dialog;
}
コード例 #30
0
gboolean
gnc_xml_convert_single_file (const gchar *filename)
{
    GncXmlImportData *data;
    GtkWidget *widget;
    GtkBuilder *builder;
    gboolean success;

    data = g_new0 (GncXmlImportData, 1);
    data->filename = gnc_uri_get_path (filename);
    data->canceled = FALSE;

    /* gather ambiguous info */
    gxi_check_file (data);
    if (data->n_impossible == -1)
        return FALSE;

    if (!g_hash_table_size (data->ambiguous_ht))
    {
        /* no ambiguous strings */
        success = gxi_parse_file (data) &&
                  gxi_save_file (data);

        gxi_data_destroy (data);
    }
    else
    {
        /* common assistant initialization */
        builder = gtk_builder_new();
        gnc_builder_add_from_file  (builder , "assistant-xml-encoding.glade", "assistant_xml_encoding");
        data->assistant = GTK_WIDGET(gtk_builder_get_object (builder, "assistant_xml_encoding"));

        /* Enable buttons on all pages. */
        gtk_assistant_set_page_complete (GTK_ASSISTANT (data->assistant),
                                         GTK_WIDGET(gtk_builder_get_object(builder, "start_page")),
                                         TRUE);
        gtk_assistant_set_page_complete (GTK_ASSISTANT (data->assistant),
                                         GTK_WIDGET(gtk_builder_get_object(builder, "conversion_page")),
                                         TRUE);
        gtk_assistant_set_page_complete (GTK_ASSISTANT (data->assistant),
                                         GTK_WIDGET(gtk_builder_get_object(builder, "end_page")),
                                         TRUE);

        /* start page, explanations */
        gtk_assistant_set_page_title (GTK_ASSISTANT(data->assistant),
                                      gtk_assistant_get_nth_page (GTK_ASSISTANT(data->assistant), 0),
                                      gettext(encodings_doc_page_title));

        widget = GTK_WIDGET(gtk_builder_get_object (builder, "start_page"));
        gtk_label_set_text (GTK_LABEL(widget), gettext (encodings_doc_string));

        /* conversion page */
        data->default_encoding_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "default_enc_box"));
        data->string_box_container = GTK_WIDGET(gtk_builder_get_object (builder, "string_box_container"));
        data->impossible_label = GTK_WIDGET(gtk_builder_get_object (builder, "impossible_label"));

        /* finish page */
        widget = GTK_WIDGET(gtk_builder_get_object(builder, "end_page"));
        gtk_label_set_text (GTK_LABEL(widget), gettext (finish_convert_string));

        gtk_builder_connect_signals(builder, data);

        gtk_widget_show_all (data->assistant);

        gxi_update_default_enc_combo (data);
        gxi_update_string_box (data);

        g_object_unref(G_OBJECT(builder));

        /* This won't return until the assistant is finished */
        gtk_main();

        if (data->canceled)
            success = FALSE;
        else
            success = gxi_save_file (data);
    }

    /* destroy all the data variables */
    gxi_data_destroy (data);
    g_free (data);

    return success;
}