48 #include <glib/gi18n.h> 54 #include "dialog-sx-editor.h" 55 #include "dialog-utils.h" 57 #include "gnc-component-manager.h" 59 #include "gnc-dense-cal.h" 63 #include "gnc-icons.h" 66 #include "gnc-plugin-page-sx-list.h" 68 #include "gnc-session.h" 69 #include "gnc-sx-instance-dense-cal-adapter.h" 71 #include "gnc-sx-list-tree-model-adapter.h" 78 #define G_LOG_DOMAIN "gnc.gui.plugin-page.sx-list" 80 G_GNUC_UNUSED
static QofLogModule log_module = GNC_MOD_GUI_SX;
82 #define PLUGIN_PAGE_SX_LIST_CM_CLASS "plugin-page-sx-list" 83 #define STATE_SECTION "SX Transaction List" 84 #define GNC_PREF_DIVIDER_POS "divider-position" 85 #define GNC_PREF_NUM_OF_MONTHS "number-of-months" 92 gint gnc_component_id;
94 GncSxInstanceDenseCalAdapter *dense_cal_model;
97 GncSxInstanceModel* instances;
98 GtkTreeView* tree_view;
103 G_DEFINE_TYPE_WITH_PRIVATE(
GncPluginPageSxList, gnc_plugin_page_sx_list, GNC_TYPE_PLUGIN_PAGE)
105 #define GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(o) \ 106 ((GncPluginPageSxListPrivate*)gnc_plugin_page_sx_list_get_instance_private ((GncPluginPageSxList*)o)) 112 static void gnc_plugin_page_sx_list_dispose (GObject *
object);
113 static void gnc_plugin_page_sx_list_finalize (GObject *
object);
115 static GtkWidget *gnc_plugin_page_sx_list_create_widget (
GncPluginPage *plugin_page);
116 static void gnc_plugin_page_sx_list_destroy_widget (
GncPluginPage *plugin_page);
117 static void gnc_plugin_page_sx_list_save_page (
GncPluginPage *plugin_page, GKeyFile *file,
const gchar *group);
118 static GncPluginPage *gnc_plugin_page_sx_list_recreate_page (GtkWidget *window, GKeyFile *file,
const gchar *group);
120 static void gppsl_row_activated_cb (GtkTreeView *tree_view, GtkTreePath *path,
121 GtkTreeViewColumn *column, gpointer user_data);
123 static void gnc_plugin_page_sx_list_cmd_new (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
124 static void gnc_plugin_page_sx_list_cmd_edit (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
125 static void gnc_plugin_page_sx_list_cmd_delete (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
126 static void gnc_plugin_page_sx_list_cmd_refresh (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
127 static void gnc_plugin_page_sx_list_cmd_save_layout (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
128 static void gnc_plugin_page_sx_list_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
131 static GActionEntry gnc_plugin_page_sx_list_actions [] =
133 {
"SxListAction",
nullptr,
nullptr,
nullptr,
nullptr },
134 {
"SxListNewAction", gnc_plugin_page_sx_list_cmd_new,
nullptr,
nullptr,
nullptr },
135 {
"SxListEditAction", gnc_plugin_page_sx_list_cmd_edit,
nullptr,
nullptr,
nullptr },
136 {
"SxListDeleteAction", gnc_plugin_page_sx_list_cmd_delete,
nullptr,
nullptr,
nullptr },
137 {
"ViewRefreshAction", gnc_plugin_page_sx_list_cmd_refresh,
nullptr,
nullptr,
nullptr },
138 {
"ViewSaveLayoutAction", gnc_plugin_page_sx_list_cmd_save_layout,
nullptr,
nullptr,
nullptr },
139 {
"EditTaxOptionsAction", gnc_plugin_page_sx_list_cmd_edit_tax_options,
nullptr,
nullptr,
nullptr },
142 static guint gnc_plugin_page_sx_list_n_actions = G_N_ELEMENTS(gnc_plugin_page_sx_list_actions);
145 static const gchar *gnc_plugin_load_ui_items [] =
151 "SchedulePlaceholder0",
161 if (
object && GNC_IS_PLUGIN_PAGE_SX_LIST(object->data))
162 plugin_page = GNC_PLUGIN_PAGE_SX_LIST(object->data);
167 return GNC_PLUGIN_PAGE(plugin_page);
176 gnc_plugin_page_sx_list_focus_widget (
GncPluginPage *sx_plugin_page)
178 if (GNC_IS_PLUGIN_PAGE_SX_LIST(sx_plugin_page))
181 GtkTreeView *tree_view = priv->tree_view;
185 g_simple_action_set_enabled (G_SIMPLE_ACTION(action),
false);
188 g_simple_action_set_enabled (G_SIMPLE_ACTION(action),
true);
191 g_simple_action_set_enabled (G_SIMPLE_ACTION(action),
false);
195 gnc_plugin_load_ui_items);
197 if (GTK_IS_TREE_VIEW(tree_view))
199 if (!gtk_widget_is_focus (GTK_WIDGET(tree_view)))
200 gtk_widget_grab_focus (GTK_WIDGET(tree_view));
209 GObjectClass *object_class = G_OBJECT_CLASS(klass);
212 object_class->dispose = gnc_plugin_page_sx_list_dispose;
213 object_class->finalize = gnc_plugin_page_sx_list_finalize;
215 gnc_plugin_class->
tab_icon = GNC_ICON_ACCOUNT;
216 gnc_plugin_class->
plugin_name = GNC_PLUGIN_PAGE_SX_LIST_NAME;
217 gnc_plugin_class->
create_widget = gnc_plugin_page_sx_list_create_widget;
218 gnc_plugin_class->
destroy_widget = gnc_plugin_page_sx_list_destroy_widget;
219 gnc_plugin_class->
save_page = gnc_plugin_page_sx_list_save_page;
220 gnc_plugin_class->
recreate_page = gnc_plugin_page_sx_list_recreate_page;
228 GSimpleActionGroup *simple_action_group;
232 parent = GNC_PLUGIN_PAGE(plugin_page);
233 g_object_set(G_OBJECT(plugin_page),
234 "page-name", _(
"Scheduled Transactions"),
235 "ui-description",
"gnc-plugin-page-sx-list.ui",
240 g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group),
241 gnc_plugin_page_sx_list_actions,
242 gnc_plugin_page_sx_list_n_actions,
248 gnc_plugin_page_sx_list_dispose (GObject *
object)
253 page = GNC_PLUGIN_PAGE_SX_LIST(
object);
254 g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(page));
255 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
256 g_return_if_fail (priv !=
nullptr);
258 g_return_if_fail (!priv->disposed);
259 priv->disposed =
true;
261 g_object_unref (G_OBJECT(priv->dense_cal_model));
262 priv->dense_cal_model =
nullptr;
263 g_object_unref (GTK_WIDGET(priv->gdcal));
264 priv->gdcal =
nullptr;
265 g_object_unref (G_OBJECT(priv->instances));
266 priv->instances =
nullptr;
268 G_OBJECT_CLASS(gnc_plugin_page_sx_list_parent_class)->dispose (
object);
273 gnc_plugin_page_sx_list_finalize (GObject *
object)
278 page = GNC_PLUGIN_PAGE_SX_LIST(
object);
279 g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(page));
280 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
281 g_return_if_fail (priv !=
nullptr);
283 G_OBJECT_CLASS(gnc_plugin_page_sx_list_parent_class)->finalize (
object);
289 gnc_plugin_page_sx_list_refresh_cb (GHashTable *changes, gpointer user_data)
291 auto page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
294 g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(page));
300 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
301 gtk_widget_queue_draw (priv->widget);
306 gnc_plugin_page_sx_list_close_cb (gpointer user_data)
314 gppsl_selection_changed_cb (GtkTreeSelection *selection, gpointer user_data)
317 GAction *edit_action, *delete_action;
318 gboolean selection_state =
true;
320 page = GNC_PLUGIN_PAGE(user_data);
323 selection_state = gtk_tree_selection_count_selected_rows (selection) == 0
326 g_simple_action_set_enabled (G_SIMPLE_ACTION(edit_action), selection_state);
327 g_simple_action_set_enabled (G_SIMPLE_ACTION(delete_action), selection_state);
336 if (reset && priv->selected_list)
338 g_list_free (priv->selected_list);
339 priv->selected_list =
nullptr;
342 priv->selected_list = g_list_prepend (priv->selected_list, sx);
350 GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(priv->tree_view));
351 gboolean found =
false;
353 if (priv->selected_list)
356 for (GList *list = priv->selected_list; list !=
nullptr; list = list->next)
358 SchedXaction *sx = GNC_SCHEDXACTION(list->data);
359 GtkTreePath *path = gtk_tree_path_new_first ();
362 while (gnc_tree_view_path_is_valid (GNC_TREE_VIEW(priv->tree_view), path))
364 SchedXaction *sx_tmp = gnc_tree_view_sx_list_get_sx_from_path (
365 GNC_TREE_VIEW_SX_LIST(priv->tree_view), path);
371 gtk_tree_path_next (path);
374 gtk_tree_selection_select_path (selection, path);
376 gtk_tree_path_free (path);
382 GtkTreePath *path = gtk_tree_path_new_first ();
383 gtk_tree_selection_select_path (selection, path);
384 gtk_tree_path_free (path);
393 GtkWidget *menu, *menuitem;
394 gchar *full_action_name;
397 menu = gtk_menu_new();
399 menuitem = gtk_menu_item_new_with_mnemonic (_(
"_New Schedule"));
400 full_action_name = g_strconcat (group_name,
".SxListNewAction",
nullptr);
401 gtk_actionable_set_action_name (GTK_ACTIONABLE(menuitem), full_action_name);
402 g_free (full_action_name);
403 gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
405 menuitem = gtk_menu_item_new_with_mnemonic (_(
"_Edit Schedule"));
406 full_action_name = g_strconcat (group_name,
".SxListEditAction",
nullptr);
407 gtk_actionable_set_action_name (GTK_ACTIONABLE(menuitem), full_action_name);
408 g_free (full_action_name);
409 gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
411 menuitem = gtk_menu_item_new_with_mnemonic (_(
"_Delete Schedule"));
412 full_action_name = g_strconcat (group_name,
".SxListDeleteAction",
nullptr);
413 gtk_actionable_set_action_name (GTK_ACTIONABLE(menuitem), full_action_name);
414 g_free (full_action_name);
415 gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
417 gtk_menu_attach_to_widget (GTK_MENU(menu), GTK_WIDGET(priv->tree_view),
nullptr);
418 gtk_widget_show_all (menu);
419 gtk_menu_popup_at_pointer (GTK_MENU(menu), event);
423 treeview_button_press (GtkTreeView *treeview, GdkEvent *event,
427 GtkTreeView *tree_view = GTK_TREE_VIEW(priv->tree_view);
429 if (event->type == GDK_BUTTON_PRESS)
431 GdkEventButton *event_button = (GdkEventButton*)event;
432 if (event_button->button == GDK_BUTTON_SECONDARY)
434 GtkTreePath *path =
nullptr;
435 if (gtk_tree_view_get_path_at_pos (priv->tree_view, event_button->x, event_button->y,
436 &path,
nullptr,
nullptr,
nullptr))
438 GtkTreeSelection *selection = gtk_tree_view_get_selection (priv->tree_view);
440 if (!gtk_tree_selection_path_is_selected (selection, path))
442 gtk_tree_selection_unselect_all (selection);
443 gtk_tree_selection_select_path (selection, path);
446 gtk_tree_path_free (path);
448 treeview_popup (tree_view, event, page);
458 treeview_popup (treeview,
nullptr, page);
463 gnc_plugin_page_sx_list_create_widget (
GncPluginPage *plugin_page)
473 page = GNC_PLUGIN_PAGE_SX_LIST(plugin_page);
474 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
475 if (priv->widget !=
nullptr)
481 widget = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
482 priv->widget = widget;
483 gtk_widget_show (priv->widget);
486 gtk_widget_set_name (GTK_WIDGET(priv->widget),
"gnc-id-sx-page");
489 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
490 gtk_box_set_homogeneous (GTK_BOX(vbox),
false);
491 gtk_paned_pack1 (GTK_PANED(widget), vbox,
true,
false);
493 label = gtk_label_new (_(
"Transactions"));
494 gnc_widget_style_context_add_class (GTK_WIDGET(label),
"gnc-class-strong");
495 gtk_widget_set_margin_start (GTK_WIDGET(label), 6);
496 gnc_label_set_alignment (label, 0.0, 0);
497 gtk_widget_show (label);
498 gtk_box_pack_start (GTK_BOX(vbox), label,
false,
false, 0);
499 gtk_widget_show (vbox);
502 swin = gtk_scrolled_window_new (
nullptr,
nullptr);
503 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(swin),
504 GTK_POLICY_AUTOMATIC,
505 GTK_POLICY_AUTOMATIC);
506 gtk_box_pack_start (GTK_BOX(vbox), swin,
true,
true, 5);
507 gtk_widget_show (swin);
510 gtk_paned_set_position (GTK_PANED(priv->widget),
512 GNC_PREF_DIVIDER_POS));
516 g_date_clear (&end, 1);
518 g_date_add_years (&end, 1);
523 GAction *edit_action, *delete_action;
526 g_simple_action_set_enabled (G_SIMPLE_ACTION(edit_action),
false);
527 g_simple_action_set_enabled (G_SIMPLE_ACTION(delete_action),
false);
531 GtkTreeSelection *selection;
532 GtkTreePath *path = gtk_tree_path_new_first ();
534 priv->tree_view = GTK_TREE_VIEW(gnc_tree_view_sx_list_new (priv->instances));
535 g_object_set (G_OBJECT(priv->tree_view),
536 "state-section", STATE_SECTION,
537 "show-column-menu",
true,
539 gtk_container_add (GTK_CONTAINER(swin), GTK_WIDGET(priv->tree_view));
541 selection = gtk_tree_view_get_selection (priv->tree_view);
542 gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
544 g_signal_connect (G_OBJECT(selection),
"changed",
545 (GCallback)gppsl_selection_changed_cb, (gpointer)page);
546 g_signal_connect (G_OBJECT(priv->tree_view),
"row-activated",
547 (GCallback)gppsl_row_activated_cb, (gpointer)page);
548 g_signal_connect (G_OBJECT(gtk_tree_view_get_model (GTK_TREE_VIEW(priv->tree_view))),
549 "model-populated", (GCallback)gppsl_model_populated_cb, (gpointer)page);
551 gtk_tree_selection_select_path (selection, path);
552 gtk_tree_path_free (path);
555 g_signal_connect (G_OBJECT(priv->tree_view),
"button-press-event",
556 G_CALLBACK(treeview_button_press), page);
557 g_signal_connect (G_OBJECT(priv->tree_view),
"popup-menu",
558 G_CALLBACK(treeview_popup_menu), page);
561 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
562 gtk_box_set_homogeneous (GTK_BOX(vbox),
false);
563 gtk_paned_pack2 (GTK_PANED(widget), vbox,
true,
false);
565 label = gtk_label_new (_(
"Upcoming Transactions"));
566 gnc_widget_style_context_add_class (GTK_WIDGET(label),
"gnc-class-strong");
567 gtk_widget_set_margin_start (GTK_WIDGET(label), 6);
568 gnc_label_set_alignment (label, 0.0, 0);
569 gtk_widget_show (label);
571 gtk_box_pack_start (GTK_BOX(vbox), label,
false,
false, 0);
572 gtk_widget_show (vbox);
575 swin = gtk_scrolled_window_new (
nullptr,
nullptr);
576 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(swin),
577 GTK_POLICY_AUTOMATIC,
578 GTK_POLICY_AUTOMATIC);
579 gtk_box_pack_start (GTK_BOX(vbox), swin,
true,
true, 5);
580 gtk_widget_show (swin);
583 priv->dense_cal_model = gnc_sx_instance_dense_cal_adapter_new (GNC_SX_INSTANCE_MODEL(priv->instances));
584 priv->gdcal = GNC_DENSE_CAL(gnc_dense_cal_new_with_model (window, GNC_DENSE_CAL_MODEL(priv->dense_cal_model)));
585 g_object_ref_sink (priv->gdcal);
589 gnc_dense_cal_set_num_months (priv->gdcal, atoi (num_months));
592 gtk_container_add (GTK_CONTAINER(swin), GTK_WIDGET(priv->gdcal));
595 priv->gnc_component_id = gnc_register_gui_component (
"plugin-page-sx-list",
596 gnc_plugin_page_sx_list_refresh_cb,
597 gnc_plugin_page_sx_list_close_cb,
599 gnc_gui_component_set_session (priv->gnc_component_id,
600 gnc_get_current_session ());
602 g_signal_connect (G_OBJECT(plugin_page),
"inserted",
611 gnc_plugin_page_sx_list_destroy_widget (
GncPluginPage *plugin_page)
616 page = GNC_PLUGIN_PAGE_SX_LIST(plugin_page);
617 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
623 g_idle_remove_by_data (plugin_page);
627 g_object_unref (G_OBJECT(priv->widget));
628 priv->widget =
nullptr;
631 if (priv->selected_list)
632 g_list_free (priv->selected_list);
634 if (priv->gnc_component_id)
636 gnc_unregister_gui_component (priv->gnc_component_id);
637 priv->gnc_component_id = 0;
650 gnc_plugin_page_sx_list_save_page (
GncPluginPage *plugin_page,
652 const gchar *group_name)
657 g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(plugin_page));
658 g_return_if_fail (key_file !=
nullptr);
659 g_return_if_fail (group_name !=
nullptr);
661 page = GNC_PLUGIN_PAGE_SX_LIST(plugin_page);
662 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
664 g_key_file_set_integer (key_file, group_name,
"dense_cal_num_months",
665 gnc_dense_cal_get_num_months (priv->gdcal));
667 g_key_file_set_integer (key_file, group_name,
"paned_position",
668 gtk_paned_get_position (GTK_PANED(priv->widget)));
681 gnc_plugin_page_sx_list_recreate_page (GtkWidget *window,
683 const gchar *group_name)
688 g_return_val_if_fail (key_file,
nullptr);
689 g_return_val_if_fail (group_name,
nullptr);
693 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
699 GError *err =
nullptr;
700 gint num_months = g_key_file_get_integer (key_file, group_name,
"dense_cal_num_months", &err);
702 gnc_dense_cal_set_num_months (priv->gdcal, num_months);
708 GError *err =
nullptr;
709 gint paned_position = g_key_file_get_integer (key_file, group_name,
710 "paned_position", &err);
712 gtk_paned_set_position (GTK_PANED(priv->widget), paned_position);
717 return GNC_PLUGIN_PAGE(page);
722 gnc_plugin_page_sx_list_cmd_new (GSimpleAction *simple,
726 auto plugin_page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
728 SchedXaction *new_sx;
729 gboolean new_sx_flag =
true;
737 g_date_clear (&now, 1);
739 recurrenceSet (r, 1, PERIOD_MONTH, &now, WEEKEND_ADJ_NONE);
741 schedule = g_list_append (schedule, r);
744 gnc_ui_scheduled_xaction_editor_dialog_create (window, new_sx, new_sx_flag);
745 gppsl_update_selected_list (plugin_page,
true, new_sx);
749 gnc_plugin_page_sx_list_cmd_refresh (GSimpleAction *simple,
753 auto plugin_page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
756 g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(plugin_page));
758 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(plugin_page);
759 gtk_widget_queue_draw (priv->widget);
763 gnc_plugin_page_sx_list_cmd_save_layout (GSimpleAction *simple,
767 auto plugin_page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
769 gchar *num_of_months;
772 g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(plugin_page));
774 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(plugin_page);
776 num_of_months = g_strdup_printf (
"%d", gnc_dense_cal_get_num_months (priv->gdcal));
777 paned_position = gtk_paned_get_position (GTK_PANED(priv->widget));
785 g_free (num_of_months);
789 _edit_sx(gpointer data, gpointer user_data)
791 gnc_ui_scheduled_xaction_editor_dialog_create (GTK_WINDOW(user_data),
792 GNC_SCHEDXACTION(data),
false);
796 _argument_reorder_fn (GtkTreePath* list_path_data, GncTreeViewSxList* user_tree_view)
798 return gnc_tree_view_sx_list_get_sx_from_path (user_tree_view, list_path_data);
803 gnc_plugin_page_sx_list_cmd_edit (GSimpleAction *simple,
807 auto plugin_page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
810 GtkTreeSelection *selection;
811 GList *selected_paths, *to_edit;
814 selection = gtk_tree_view_get_selection (priv->tree_view);
815 selected_paths = gtk_tree_selection_get_selected_rows (selection, &model);
818 g_warning (
"no selection edit.");
823 (GncGMapFunc)_argument_reorder_fn,
826 gppsl_update_selected_list (plugin_page,
true,
nullptr);
827 for (GList *list = to_edit; list !=
nullptr; list = list->next)
829 DEBUG (
"to-edit [%s]\n", xaccSchedXactionGetName (GNC_SCHEDXACTION(list->data)));
830 gppsl_update_selected_list (plugin_page,
false, GNC_SCHEDXACTION(list->data));
833 g_list_foreach (to_edit, (GFunc)_edit_sx, window);
834 g_list_free (to_edit);
835 g_list_foreach (selected_paths, (GFunc)gtk_tree_path_free,
nullptr);
836 g_list_free (selected_paths);
841 gnc_plugin_page_sx_list_cmd_edit_tax_options (GSimpleAction *simple,
845 auto plugin_page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
848 ENTER (
"(action %p, page %p)", simple, plugin_page);
849 gnc_tax_info_dialog (window,
nullptr);
855 gppsl_row_activated_cb (GtkTreeView *tree_view,
857 GtkTreeViewColumn *column,
864 SchedXaction *sx = gnc_tree_view_sx_list_get_sx_from_path (
865 GNC_TREE_VIEW_SX_LIST(priv->tree_view), path);
866 gnc_ui_scheduled_xaction_editor_dialog_create (window, sx,
false);
867 gppsl_update_selected_list (page,
true, sx);
872 _destroy_sx(gpointer data, gpointer user_data)
875 auto sx = GNC_SCHEDXACTION(data);
877 book = gnc_get_current_book ();
878 sxes = gnc_book_get_schedxactions (book);
880 DEBUG(
"deleting sx [%s]", xaccSchedXactionGetName (sx));
882 gnc_sxes_del_sx (sxes, sx);
883 gnc_sx_begin_edit (sx);
889 _destroy_sx_names (gpointer data, gpointer user_data)
891 auto sx = GNC_SCHEDXACTION(data);
892 GList **to_delete_names = (GList**)user_data;
893 *to_delete_names = g_list_append (*to_delete_names, xaccSchedXactionGetName (sx));
898 gnc_plugin_page_sx_list_cmd_delete (GSimpleAction *simple,
902 auto plugin_page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
904 GtkTreeSelection *selection = gtk_tree_view_get_selection (priv->tree_view);
905 GList *selected_paths, *to_delete =
nullptr, *to_delete_names =
nullptr;
908 gchar *message =
nullptr;
910 gchar *text_list_of_scheduled_transaction_names =
nullptr;
912 selected_paths = gtk_tree_selection_get_selected_rows (selection, &model);
915 g_warning (
"no selection for delete.");
920 (GncGMapFunc)_argument_reorder_fn,
923 g_list_foreach (to_delete, (GFunc)_destroy_sx_names, &to_delete_names);
927 length = g_list_length (to_delete);
932 message = g_strdup_printf (
"%s\n\n%s",
933 ngettext (
"Do you really want to delete this scheduled transaction?",
934 "Do you really want to delete these scheduled transactions?",
936 text_list_of_scheduled_transaction_names);
938 g_free (text_list_of_scheduled_transaction_names);
939 g_list_free (to_delete_names);
941 if (gnc_verify_dialog (window,
false,
"%s", message))
943 gppsl_update_selected_list (plugin_page,
true,
nullptr);
945 g_list_foreach (to_delete, (GFunc)_destroy_sx,
nullptr);
949 g_list_free (to_delete);
950 g_list_foreach (selected_paths, (GFunc)gtk_tree_path_free,
nullptr);
951 g_list_free (selected_paths);
GtkWidget * gnc_plugin_page_get_window(GncPluginPage *page)
Retrieve a pointer to the GncMainWindow (GtkWindow) containing this page.
void gnc_sx_set_schedule(SchedXaction *sx, GList *schedule)
GList * gnc_g_list_map(GList *list, GncGMapFunc fn, gpointer user_data)
const gchar * tab_icon
The relative name of the icon that should be shown on the tab for this page.
gboolean(* focus_page_function)(GncPluginPage *plugin_page)
This function performs specific actions to set the focus on a specific widget.
GList * gnc_sx_get_schedule(const SchedXaction *sx)
void gnc_main_window_update_menu_and_toolbar(GncMainWindow *window, GncPluginPage *page, const gchar **ui_updates)
Update the main window menu with the placeholders listed in ui_updates and load the page specific too...
The instance data structure for a content plugin.
gchar * gnc_prefs_get_string(const gchar *group, const gchar *pref_name)
Get a string value from the preferences backend.
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.
Date and Time handling routines.
gchar * gnc_g_list_stringjoin(GList *list_of_strings, const gchar *sep)
Return a string joining a GList whose elements are gchar* strings.
utility functions for the GnuCash UI
GncTreeView implementation for Scheduled Transaction List.
GncPluginPage *(* recreate_page)(GtkWidget *window, GKeyFile *file, const gchar *group)
Create a new page based on the information saved during a previous instantiation of gnucash...
#define DEBUG(format, args...)
Print a debugging message.
Functions that are supported by all types of windows.
void gnc_gdate_set_today(GDate *gd)
Set a GDate to the current day.
GtkWidget * window
The window that contains the display widget for this plugin.
API for Transactions and Splits (journal entries)
GSimpleActionGroup * gnc_plugin_page_create_action_group(GncPluginPage *page, const gchar *group_name)
Create the GSimpleActionGroup object associated with this page.
gboolean gnc_prefs_set_string(const gchar *group, const gchar *pref_name, const gchar *value)
Store a string into the preferences backend.
#define ENTER(format, args...)
Print a function entry debugging message.
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Display a data plugin page in a window.
Functions for adding content to a window.
void(* destroy_widget)(GncPluginPage *plugin_page)
Function called to destroy the display widget for a particular type of plugin.
The class data structure for a content plugin.
GAction * gnc_main_window_find_action(GncMainWindow *window, const gchar *action_name)
Find the GAction in the main window.
void gnc_plugin_page_disconnect_page_changed(GncPluginPage *page)
Disconnect the page_changed_id signal callback.
Anchor Scheduled Transaction info in a book.
const gchar * plugin_name
The textual name of this plugin.
gboolean gnc_prefs_set_float(const gchar *group, const gchar *pref_name, gdouble value)
Store a float value into the preferences backend.
GtkWidget *(* create_widget)(GncPluginPage *plugin_page)
Function called to create the display widget for a particular type of plugin.
const gchar * gnc_plugin_page_get_simple_action_group_name(GncPluginPage *page)
Retrieve the simple action group name associated with this plugin page.
Additional event handling code.
All type declarations for the whole Gnucash engine.
void(* save_page)(GncPluginPage *page, GKeyFile *file, const gchar *group)
Save enough information about this page so that it can be recreated next time the user starts gnucash...
Generic api to store and retrieve preferences.
GncSxInstanceModel * gnc_sx_get_instances(const GDate *range_end, gboolean include_disabled)
Allocates a new SxInstanceModel and fills it with generated instances for all scheduled transactions ...
void gnc_plugin_page_inserted_cb(GncPluginPage *page, gpointer user_data)
Set up the page_changed callback for when the current page is changed.
void gnc_main_window_close_page(GncPluginPage *page)
Remove a data plugin page from a window and display the previous page.
Functions for adding plugins to a GnuCash window.
#define LEAVE(format, args...)
Print a function exit debugging message.
#define GNC_TYPE_PLUGIN_PAGE_SX_LIST
Functions providing a list of scheduled transactions as a plugin page.
GncPluginPage * gnc_plugin_page_sx_list_new(void)
void gnc_plugin_page_add_book(GncPluginPage *page, QofBook *book)
Add a book reference to the specified page.
SchedXaction * xaccSchedXactionMalloc(QofBook *book)
Creates and initializes a scheduled transaction.
gint gnc_list_length_cmp(const GList *list, size_t len)
Scans the GList elements the minimum number of iterations required to test it against a specified siz...
API for Transactions and Splits (journal entries)
GAction * gnc_plugin_page_get_action(GncPluginPage *page, const gchar *name)
Retrieve a GAction object associated with this page.
void xaccSchedXactionDestroy(SchedXaction *sx)
Cleans up and frees a SchedXaction and its associated data.
Commodity handling public routines.
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
Get an float value from the preferences backend.