Exemple #1
0
/********************************************************************\
 * gnc_find_account_dialog                                          *
 * opens a window allowing for searches on account names            *
 *                                                                  *
 * Args:   parent  - the parent of the window to be created         *
 * Return: nothing                                                  *
\********************************************************************/
void
gnc_find_account_dialog (GtkWidget *parent, Account *account)
{
    FindAccountDialog *facc_dialog;
    gint component_id;

    ENTER(" ");
    if (gnc_forall_gui_components (DIALOG_FIND_ACCOUNT_CM_CLASS, show_handler, NULL))
    {
        LEAVE("Existing dialog raised");
        return;
    }
    facc_dialog = g_new0 (FindAccountDialog, 1);

    facc_dialog->account = account;
    facc_dialog->jump_close = TRUE;

    gnc_find_account_dialog_create (parent, facc_dialog);

    component_id = gnc_register_gui_component (DIALOG_FIND_ACCOUNT_CM_CLASS,
                   refresh_handler, close_handler,
                   facc_dialog);

    gnc_gui_component_set_session (component_id, facc_dialog->session);

    gtk_widget_show (facc_dialog->dialog);
    LEAVE(" ");
}
Exemple #2
0
static void
setup_dialog(GncGWENGui *gui)
{
    GladeXML *xml;
    gint component_id;

    g_return_if_fail(gui);

    ENTER("gui=%p", gui);

    xml = gnc_glade_xml_new("aqbanking.glade", "Connection Dialog");

    gui->dialog = glade_xml_get_widget(xml, "Connection Dialog");
    g_object_set_data_full(G_OBJECT(gui->dialog), "xml", xml, g_object_unref);
    glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, gui);
    gui->entries_table = glade_xml_get_widget(xml, "entries_table");
    gui->top_entry = glade_xml_get_widget(xml, "top_entry");
    gui->top_progress = glade_xml_get_widget(xml, "top_progress");
    gui->second_entry = glade_xml_get_widget(xml, "second_entry");
    gui->other_entries_box = NULL;
    gui->progresses = NULL;
    gui->log_text = glade_xml_get_widget(xml, "log_text");
    gui->abort_button = glade_xml_get_widget(xml, "abort_button");
    gui->close_button = glade_xml_get_widget(xml, "close_button");
    gui->close_checkbutton = glade_xml_get_widget(xml, "close_checkbutton");
    gui->accepted_certs = NULL;
    gui->permanently_accepted_certs = NULL;
    gui->showbox_hash = NULL;
    gui->showbox_id = 1;

    gtk_toggle_button_set_active(
        GTK_TOGGLE_BUTTON(gui->close_checkbutton),
        gnc_gconf_get_bool(GCONF_SECTION_AQBANKING, KEY_CLOSE_ON_FINISH, NULL));

    component_id = gnc_register_gui_component(GWEN_GUI_CM_CLASS, NULL,
                   cm_close_handler, gui);
    gnc_gui_component_set_session(component_id, gnc_get_current_session());

    reset_dialog(gui);

    LEAVE(" ");
}
/********************************************************************\
 * gnc_commodities_dialog                                           *
 *   opens up a window to edit price information                    *
 *                                                                  *
 * Args:   parent  - the parent of the window to be created         *
 * Return: nothing                                                  *
\********************************************************************/
void
gnc_commodities_dialog (GtkWidget * parent)
{
    CommoditiesDialog *cd;
    gint component_id;

    if (gnc_forall_gui_components (DIALOG_COMMODITIES_CM_CLASS,
                                   show_handler, NULL))
        return;

    cd = g_new0 (CommoditiesDialog, 1);

    gnc_commodities_dialog_create (parent, cd);

    component_id = gnc_register_gui_component (DIALOG_COMMODITIES_CM_CLASS,
                   refresh_handler, close_handler,
                   cd);
    gnc_gui_component_set_session (component_id, cd->session);

    gtk_widget_grab_focus (GTK_WIDGET(cd->commodity_tree));

    gtk_widget_show (cd->dialog);
}
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;
}
Exemple #5
0
void
gnc_ab_initial_druid(void)
{
    ABInitialInfo *info;
    GladeXML *xml;
    GtkTreeViewColumn *column;
    GtkTreeSelection *selection;
    gint component_id;

    info = g_new0(ABInitialInfo, 1);

    xml = gnc_glade_xml_new("aqbanking.glade", "AqBanking Init Druid");

    info->window = glade_xml_get_widget(xml, "AqBanking Init Druid");
    g_object_set_data_full(G_OBJECT(info->window), "xml", xml, g_object_unref);
    glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
                                      info);

    info->druid = glade_xml_get_widget(xml, "ab_init_druid");
    gnc_druid_set_colors(GNOME_DRUID(info->druid));

    info->api = gnc_AB_BANKING_new();
    info->deferred_info = NULL;
    info->gnc_hash = NULL;

    info->match_page_prepared = FALSE;
    info->account_view =
        GTK_TREE_VIEW(glade_xml_get_widget(xml, "account_page_view"));
    info->account_store = gtk_list_store_new(NUM_ACCOUNT_LIST_COLS,
                          G_TYPE_INT, G_TYPE_STRING,
                          G_TYPE_POINTER, G_TYPE_STRING,
                          G_TYPE_BOOLEAN);
    gtk_tree_view_set_model(info->account_view,
                            GTK_TREE_MODEL(info->account_store));
    g_object_unref(info->account_store);

    column = gtk_tree_view_column_new_with_attributes(
                 _("Online Banking Account Name"), gtk_cell_renderer_text_new(),
                 "text", ACCOUNT_LIST_COL_AB_NAME, (gchar*) NULL);
    gtk_tree_view_append_column(info->account_view, column);

    column = gtk_tree_view_column_new_with_attributes(
                 _("GnuCash Account Name"), gtk_cell_renderer_text_new(),
                 "text", ACCOUNT_LIST_COL_GNC_NAME, (gchar*) NULL);
    gtk_tree_view_column_set_expand(column, TRUE);
    gtk_tree_view_append_column(info->account_view, column);

    column = gtk_tree_view_column_new_with_attributes(
                 _("New?"), gtk_cell_renderer_toggle_new(),
                 "active", ACCOUNT_LIST_COL_CHECKED, (gchar*) NULL);
    gtk_tree_view_append_column(info->account_view, column);

    selection = gtk_tree_view_get_selection(info->account_view);
    g_signal_connect(selection, "changed",
                     G_CALLBACK(account_list_changed_cb), info);

    component_id = gnc_register_gui_component(DRUID_AB_INITIAL_CM_CLASS,
                   NULL, cm_close_handler, info);
    gnc_gui_component_set_session(component_id, gnc_get_current_session());

    gtk_widget_show(info->window);
}
static GtkWidget *
gnc_plugin_page_sx_list_create_widget (GncPluginPage *plugin_page)
{
    GncPluginPageSxList *page;
    GncPluginPageSxListPrivate *priv;
    GtkWidget *widget;
    GtkWidget *vbox;
    GtkWidget *label;
    GtkWidget *swin;
    char *markup;
    char *text;

    page = GNC_PLUGIN_PAGE_SX_LIST(plugin_page);
    priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
    if (priv->widget != NULL)
        return priv->widget;

    /* Create Vpaned widget for top level */
    widget = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
    priv->widget = widget;
    gtk_widget_show (priv->widget);

    // Set the style context for this page so it can be easily manipulated with css
    gnc_widget_set_style_context (GTK_WIDGET(priv->widget), "GncSxPage");

    /* Add vbox and label */
    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);
    gtk_paned_pack1( GTK_PANED(widget), vbox, TRUE, FALSE);

    label = gtk_label_new(NULL);
    text = g_strdup_printf(_("Transactions"));
    markup = g_markup_printf_escaped ("<b> %s</b>", text);
    gtk_label_set_markup (GTK_LABEL (label), markup);
    g_free (markup);
    g_free (text);
    gnc_label_set_alignment (label, 0.0, 0);
    gtk_widget_show (label);
    gtk_box_pack_start ( GTK_BOX(vbox), label, FALSE, FALSE, 0);
    gtk_widget_show (vbox);

    /* Create scrolled window for top area */
    swin = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start ( GTK_BOX(vbox), swin, TRUE, TRUE, 5);
    gtk_widget_show (swin);

    {
        // gint half_way;
        // half_way = plugin_page->notebook_page->allocation.height * 0.5;
        // fixme; get a real value:
        gtk_paned_set_position(GTK_PANED(priv->widget), 160);
    }

    {
        GDate end;
        g_date_clear(&end, 1);
        gnc_gdate_set_today (&end);
        g_date_add_years(&end, 1);
        priv->instances = GNC_SX_INSTANCE_MODEL(gnc_sx_get_instances(&end, TRUE));
    }

    {
        GtkAction *edit_action, *delete_action;
        edit_action = gnc_plugin_page_get_action(GNC_PLUGIN_PAGE(page), "SxListEditAction");
        delete_action = gnc_plugin_page_get_action(GNC_PLUGIN_PAGE(page), "SxListDeleteAction");
        gtk_action_set_sensitive(edit_action, FALSE);
        gtk_action_set_sensitive(delete_action, FALSE);
    }

    {
        GtkTreeSelection *selection;

        priv->tree_view = GTK_TREE_VIEW(gnc_tree_view_sx_list_new(priv->instances));
        g_object_set(G_OBJECT(priv->tree_view),
                     "state-section", STATE_SECTION,
                     "show-column-menu", TRUE,
                     NULL);
        gtk_container_add(GTK_CONTAINER( swin ), GTK_WIDGET(priv->tree_view));

        selection = gtk_tree_view_get_selection(priv->tree_view);
        gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
        g_signal_connect(G_OBJECT(selection), "changed", (GCallback)gppsl_selection_changed_cb, (gpointer)page);
        g_signal_connect(G_OBJECT(priv->tree_view), "row-activated", (GCallback)gppsl_row_activated_cb, (gpointer)page);
    }

    /* Add vbox and label */
    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);;
    gtk_paned_pack2( GTK_PANED(widget), vbox, TRUE, FALSE);

    label = gtk_label_new(NULL);
    text = g_strdup_printf(_("Upcoming Transactions"));
    markup = g_markup_printf_escaped ("<b> %s</b>", text);
    gtk_label_set_markup (GTK_LABEL (label), markup);
    g_free (markup);
    g_free (text);
    gnc_label_set_alignment (label, 0.0, 0);
    gtk_widget_show (label);

    gtk_box_pack_start ( GTK_BOX(vbox), label, FALSE, FALSE, 0);
    gtk_widget_show (vbox);

    /* Create scrolled window for bottom area */
    swin = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start ( GTK_BOX(vbox), swin, TRUE, TRUE, 5);
    gtk_widget_show (swin);

    {
        priv->dense_cal_model = gnc_sx_instance_dense_cal_adapter_new(GNC_SX_INSTANCE_MODEL(priv->instances));
        priv->gdcal = GNC_DENSE_CAL(gnc_dense_cal_new_with_model(GNC_DENSE_CAL_MODEL(priv->dense_cal_model)));
        g_object_ref_sink(priv->gdcal);

        gnc_dense_cal_set_months_per_col(priv->gdcal, 4);
        gnc_dense_cal_set_num_months(priv->gdcal, 12);

        gtk_container_add (GTK_CONTAINER(swin), GTK_WIDGET(priv->gdcal));
    }

    priv->gnc_component_id = gnc_register_gui_component("plugin-page-sx-list",
                             gnc_plugin_page_sx_list_refresh_cb,
                             gnc_plugin_page_sx_list_close_cb,
                             page);
    gnc_gui_component_set_session (priv->gnc_component_id,
                                   gnc_get_current_session());

    return priv->widget;
}
static GtkWidget *
gnc_plugin_page_owner_tree_create_widget (GncPluginPage *plugin_page)
{
    GncPluginPageOwnerTree *page;
    GncPluginPageOwnerTreePrivate *priv;
    GtkTreeSelection *selection;
    GtkTreeView *tree_view;
    GtkWidget *scrolled_window;
    GtkTreeViewColumn *col;
    const gchar *state_section = NULL;
    gchar* label = "";

    ENTER("page %p", plugin_page);
    page = GNC_PLUGIN_PAGE_OWNER_TREE (plugin_page);
    priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
    if (priv->widget != NULL)
    {
        LEAVE("widget = %p", priv->widget);
        return priv->widget;
    }

    priv->widget = gtk_vbox_new (FALSE, 0);
    gtk_widget_show (priv->widget);

    scrolled_window = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
                                    GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    gtk_widget_show (scrolled_window);
    gtk_box_pack_start (GTK_BOX (priv->widget), scrolled_window,
                        TRUE, TRUE, 0);

    tree_view = gnc_tree_view_owner_new(priv->owner_type);

    /* Show default columns */
    col = gnc_tree_view_find_column_by_name(
              GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ID_COL);
    g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
    col = gnc_tree_view_find_column_by_name(
              GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ADDRESS_1_COL);
    g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
    col = gnc_tree_view_find_column_by_name(
              GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ADDRESS_2_COL);
    g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
    col = gnc_tree_view_find_column_by_name(
              GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_PHONE_COL);
    g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
    gnc_tree_view_configure_columns(GNC_TREE_VIEW(tree_view));



    switch (priv->owner_type)
    {
    case GNC_OWNER_NONE :
    case GNC_OWNER_UNDEFINED :
        break;
    case GNC_OWNER_CUSTOMER :
        label = N_("Customers");
        state_section = "Customers Overview";
        break;
    case GNC_OWNER_JOB :
        label = N_("Jobs");
        state_section = "Jobs Overview";
        break;
    case GNC_OWNER_VENDOR :
        label = N_("Vendors");
        state_section = "Vendors Overview";
        break;
    case GNC_OWNER_EMPLOYEE :
        label = N_("Employees");
        state_section = "Employees Overview";
        break;
    }

    g_object_set(G_OBJECT(tree_view), "state-section", state_section,
                                      "show-column-menu", TRUE,
                                      NULL);

    g_object_set(G_OBJECT(plugin_page), "page-name", label, NULL);

    priv->tree_view = tree_view;
    selection = gtk_tree_view_get_selection(tree_view);
    g_signal_connect (G_OBJECT (selection), "changed",
                      G_CALLBACK (gnc_plugin_page_owner_tree_selection_changed_cb), page);
    g_signal_connect (G_OBJECT (tree_view), "button-press-event",
                      G_CALLBACK (gnc_plugin_page_owner_tree_button_press_cb), page);
    g_signal_connect (G_OBJECT (tree_view), "row-activated",
                      G_CALLBACK (gnc_plugin_page_owner_tree_double_click_cb), page);

    gtk_tree_view_set_headers_visible(tree_view, TRUE);
    gnc_plugin_page_owner_tree_selection_changed_cb (NULL, page);
    gtk_widget_show (GTK_WIDGET (tree_view));
    gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET(tree_view));

    priv->fd.tree_view = GNC_TREE_VIEW_OWNER(priv->tree_view);
    gnc_tree_view_owner_set_filter (
        GNC_TREE_VIEW_OWNER(tree_view),
        gnc_plugin_page_owner_tree_filter_owners, &priv->fd, NULL);

    priv->component_id =
        gnc_register_gui_component(PLUGIN_PAGE_ACCT_TREE_CM_CLASS,
                                   gnc_plugin_page_owner_refresh_cb,
                                   gnc_plugin_page_owner_tree_close_cb,
                                   page);
    gnc_gui_component_set_session (priv->component_id,
                                   gnc_get_current_session());

    LEAVE("widget = %p", priv->widget);
    return priv->widget;
}