void gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, gboolean can_unpost) { GtkActionGroup *action_group; gboolean is_readonly = qof_book_is_readonly(gnc_get_current_book()); g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(page)); if (is_readonly) { // Are we readonly? Then don't allow any actions. is_posted = TRUE; can_unpost = FALSE; } action_group = gnc_plugin_page_get_action_group(page); gnc_plugin_update_actions (action_group, posted_actions, "sensitive", is_posted); gnc_plugin_update_actions (action_group, unposted_actions, "sensitive", !is_posted); gnc_plugin_update_actions (action_group, can_unpost_actions, "sensitive", can_unpost); gnc_plugin_update_actions (action_group, invoice_book_readwrite_actions, "sensitive", !is_readonly); }
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); }
GncPluginPage * gnc_plugin_page_owner_tree_new (GncOwnerType owner_type) { GncPluginPageOwnerTree *plugin_page; GncPluginPageOwnerTreePrivate *priv; const GList *item; GtkActionGroup *action_group; GtkAction *action; GValue gvalue = { 0 }; gint i; g_return_val_if_fail( (owner_type != GNC_OWNER_UNDEFINED) && (owner_type != GNC_OWNER_NONE), NULL); ENTER(" "); /* Is there an existing page? */ item = gnc_gobject_tracking_get_list(GNC_PLUGIN_PAGE_OWNER_TREE_NAME); for ( ; item; item = g_list_next(item)) { plugin_page = (GncPluginPageOwnerTree *)item->data; priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page); if (priv->owner_type == owner_type) { LEAVE("existing %s tree page %p", gncOwnerTypeToQofIdType(owner_type), plugin_page); return GNC_PLUGIN_PAGE(plugin_page); } } plugin_page = g_object_new(GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, NULL); priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page); priv->owner_type = owner_type; /* Hide menu and toolbar items that are not relevant for the active owner list */ action_group = gnc_plugin_page_get_action_group(GNC_PLUGIN_PAGE(plugin_page)); g_value_init (&gvalue, G_TYPE_BOOLEAN); for (i = 0; action_owners[i].action_name; i++) { action = gtk_action_group_get_action (action_group, action_owners[i].action_name); g_value_set_boolean (&gvalue, (priv->owner_type == action_owners[i].owner_type) ); g_object_set_property (G_OBJECT(action), "visible", &gvalue); } LEAVE("new %s tree page %p", gncOwnerTypeToQofIdType(owner_type), plugin_page); return GNC_PLUGIN_PAGE(plugin_page); }
static void update_inactive_actions(GncPluginPage *plugin_page) { GtkActionGroup *action_group; gboolean is_sensitive = !qof_book_is_readonly(gnc_get_current_book()); // We are readonly - so we have to switch particular actions to inactive. g_return_if_fail(plugin_page); g_return_if_fail(GNC_IS_PLUGIN_PAGE(plugin_page)); /* Get the action group */ action_group = gnc_plugin_page_get_action_group(plugin_page); g_return_if_fail(GTK_IS_ACTION_GROUP (action_group)); /* Set the action's sensitivity */ gnc_plugin_update_actions (action_group, readonly_inactive_actions, "sensitive", is_sensitive); }