static void
gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection,
        GncPluginPageOwnerTree *page)
{
    GtkActionGroup *action_group;
    GtkTreeView *view;
    GncOwner *owner = NULL;
    gboolean sensitive;
    gboolean is_readwrite = !qof_book_is_readonly(gnc_get_current_book());

    g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));

    if (!selection)
    {
        sensitive = FALSE;
    }
    else
    {
        g_return_if_fail(GTK_IS_TREE_SELECTION(selection));
        view = gtk_tree_selection_get_tree_view (selection);
        owner = gnc_tree_view_owner_get_selected_owner (GNC_TREE_VIEW_OWNER(view));
        sensitive = (owner != NULL);
    }

    action_group = gnc_plugin_page_get_action_group(GNC_PLUGIN_PAGE(page));
    gnc_plugin_update_actions (action_group, actions_requiring_owner_always,
                               "sensitive", sensitive);
    gnc_plugin_update_actions (action_group, actions_requiring_owner_rw,
                               "sensitive", sensitive && is_readwrite);
    g_signal_emit (page, plugin_page_signals[OWNER_SELECTED], 0, owner);
}
GncOwner *
gnc_plugin_page_owner_tree_get_current_owner (GncPluginPageOwnerTree *page)
{
    GncPluginPageOwnerTreePrivate *priv;
    GncOwner *owner;

    priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
    ENTER("page %p (tree view %p)", page, priv->tree_view);
    owner = gnc_tree_view_owner_get_selected_owner (GNC_TREE_VIEW_OWNER(priv->tree_view));
    if (owner == NULL)
    {
        LEAVE("no owner");
        return NULL;
    }

    LEAVE("owner %p", owner);
    return owner;
}
Esempio n. 3
0
/** Save information about the selected row.  Its job is to write the
 *  full owner name of the row out to the state file.
 *
 *  @param view A pointer to the GtkTreeView embedded in an
 *  owner tree page.
 *
 *  @param path A pointer to a particular entry in the tree.
 *
 *  @param data A pointer to a data structure holding the information
 *  related to the state file. */
static void
tree_save_selected_row (GncTreeViewOwner *view,
                        gpointer user_data)
{
    GncOwner *owner;
    GncOwnerType owner_type;
    bar_t *bar = user_data;
    const gchar *owner_name;

    owner = gnc_tree_view_owner_get_selected_owner(view);
    if (owner == NULL)
        return;

    owner_name = gncOwnerGetName (owner);
    if (owner_name == NULL)
        return;

    g_key_file_set_string(bar->key_file, bar->group_name, OWNER_SELECTED_LABEL,
                          owner_name);
}