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, GtkTreeViewColumn *column, gpointer user_data);
122 static void gnc_plugin_page_sx_list_cmd_new (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
123 static void gnc_plugin_page_sx_list_cmd_edit (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
124 static void gnc_plugin_page_sx_list_cmd_delete (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
125 static void gnc_plugin_page_sx_list_cmd_refresh (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
126 static void gnc_plugin_page_sx_list_cmd_save_layout (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
127 static void gnc_plugin_page_sx_list_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
130 static GActionEntry gnc_plugin_page_sx_list_actions [] =
132 {
"SxListAction", NULL, NULL, NULL, NULL },
133 {
"SxListNewAction", gnc_plugin_page_sx_list_cmd_new, NULL, NULL, NULL },
134 {
"SxListEditAction", gnc_plugin_page_sx_list_cmd_edit, NULL, NULL, NULL },
135 {
"SxListDeleteAction", gnc_plugin_page_sx_list_cmd_delete, NULL, NULL, NULL },
136 {
"ViewRefreshAction", gnc_plugin_page_sx_list_cmd_refresh, NULL, NULL, NULL },
137 {
"ViewSaveLayoutAction", gnc_plugin_page_sx_list_cmd_save_layout, NULL, NULL, NULL },
138 {
"EditTaxOptionsAction", gnc_plugin_page_sx_list_cmd_edit_tax_options, NULL, NULL, NULL },
141 static guint gnc_plugin_page_sx_list_n_actions = G_N_ELEMENTS(gnc_plugin_page_sx_list_actions);
144 static const gchar *gnc_plugin_load_ui_items [] =
150 "SchedulePlaceholder0",
160 if (
object && GNC_IS_PLUGIN_PAGE_SX_LIST (object->data))
161 plugin_page = GNC_PLUGIN_PAGE_SX_LIST (object->data);
166 return GNC_PLUGIN_PAGE(plugin_page);
175 gnc_plugin_page_sx_list_focus_widget (
GncPluginPage *sx_plugin_page)
177 if (GNC_IS_PLUGIN_PAGE_SX_LIST(sx_plugin_page))
180 GtkTreeView *tree_view = priv->tree_view;
184 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
187 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE);
190 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
194 gnc_plugin_load_ui_items);
196 if (GTK_IS_TREE_VIEW(tree_view))
198 if (!gtk_widget_is_focus (GTK_WIDGET(tree_view)))
199 gtk_widget_grab_focus (GTK_WIDGET(tree_view));
208 GObjectClass *object_class = G_OBJECT_CLASS(klass);
211 object_class->dispose = gnc_plugin_page_sx_list_dispose;
212 object_class->finalize = gnc_plugin_page_sx_list_finalize;
214 gnc_plugin_class->
tab_icon = GNC_ICON_ACCOUNT;
215 gnc_plugin_class->
plugin_name = GNC_PLUGIN_PAGE_SX_LIST_NAME;
216 gnc_plugin_class->
create_widget = gnc_plugin_page_sx_list_create_widget;
217 gnc_plugin_class->
destroy_widget = gnc_plugin_page_sx_list_destroy_widget;
218 gnc_plugin_class->
save_page = gnc_plugin_page_sx_list_save_page;
219 gnc_plugin_class->
recreate_page = gnc_plugin_page_sx_list_recreate_page;
227 GSimpleActionGroup *simple_action_group;
231 parent = GNC_PLUGIN_PAGE(plugin_page);
232 g_object_set(G_OBJECT(plugin_page),
233 "page-name", _(
"Scheduled Transactions"),
234 "ui-description",
"gnc-plugin-page-sx-list.ui",
239 g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group),
240 gnc_plugin_page_sx_list_actions,
241 gnc_plugin_page_sx_list_n_actions,
247 gnc_plugin_page_sx_list_dispose (GObject *
object)
252 page = GNC_PLUGIN_PAGE_SX_LIST(
object);
253 g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(page));
254 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
255 g_return_if_fail (priv != NULL);
257 g_return_if_fail (!priv->disposed);
258 priv->disposed = TRUE;
260 g_object_unref (G_OBJECT(priv->dense_cal_model));
261 priv->dense_cal_model = NULL;
262 g_object_unref (GTK_WIDGET(priv->gdcal));
264 g_object_unref (G_OBJECT(priv->instances));
265 priv->instances = NULL;
267 G_OBJECT_CLASS(gnc_plugin_page_sx_list_parent_class)->dispose (
object);
272 gnc_plugin_page_sx_list_finalize (GObject *
object)
277 page = GNC_PLUGIN_PAGE_SX_LIST(
object);
278 g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(page));
279 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
280 g_return_if_fail (priv != NULL);
282 G_OBJECT_CLASS(gnc_plugin_page_sx_list_parent_class)->finalize (
object);
288 gnc_plugin_page_sx_list_refresh_cb (GHashTable *changes, gpointer user_data)
290 auto page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
293 g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(page));
299 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
300 gtk_widget_queue_draw (priv->widget);
305 gnc_plugin_page_sx_list_close_cb (gpointer user_data)
313 gppsl_selection_changed_cb (GtkTreeSelection *selection, gpointer user_data)
316 GAction *edit_action, *delete_action;
317 gboolean selection_state = TRUE;
319 page = GNC_PLUGIN_PAGE(user_data);
322 selection_state = gtk_tree_selection_count_selected_rows (selection) == 0
325 g_simple_action_set_enabled (G_SIMPLE_ACTION(edit_action), selection_state);
326 g_simple_action_set_enabled (G_SIMPLE_ACTION(delete_action), selection_state);
335 if (reset && priv->selected_list)
337 g_list_free (priv->selected_list);
338 priv->selected_list = NULL;
341 priv->selected_list = g_list_prepend (priv->selected_list, sx);
349 GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(priv->tree_view));
350 gboolean found = FALSE;
352 if (priv->selected_list)
355 for (GList *list = priv->selected_list; list != NULL; list = list->next)
357 SchedXaction *sx = GNC_SCHEDXACTION(list->data);
358 GtkTreePath *path = gtk_tree_path_new_first ();
361 while (gnc_tree_view_path_is_valid (GNC_TREE_VIEW(priv->tree_view), path))
363 SchedXaction *sx_tmp = gnc_tree_view_sx_list_get_sx_from_path (
364 GNC_TREE_VIEW_SX_LIST(priv->tree_view), path);
370 gtk_tree_path_next (path);
373 gtk_tree_selection_select_path (selection, path);
375 gtk_tree_path_free (path);
381 GtkTreePath *path = gtk_tree_path_new_first ();
382 gtk_tree_selection_select_path (selection, path);
383 gtk_tree_path_free (path);
392 GtkWidget *menu, *menuitem;
393 gchar *full_action_name;
396 menu = gtk_menu_new();
398 menuitem = gtk_menu_item_new_with_mnemonic (_(
"_New Schedule"));
399 full_action_name = g_strconcat (group_name,
".SxListNewAction", NULL);
400 gtk_actionable_set_action_name (GTK_ACTIONABLE(menuitem), full_action_name);
401 g_free (full_action_name);
402 gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
404 menuitem = gtk_menu_item_new_with_mnemonic (_(
"_Edit Schedule"));
405 full_action_name = g_strconcat (group_name,
".SxListEditAction", NULL);
406 gtk_actionable_set_action_name (GTK_ACTIONABLE(menuitem), full_action_name);
407 g_free (full_action_name);
408 gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
410 menuitem = gtk_menu_item_new_with_mnemonic (_(
"_Delete Schedule"));
411 full_action_name = g_strconcat (group_name,
".SxListDeleteAction", NULL);
412 gtk_actionable_set_action_name (GTK_ACTIONABLE(menuitem), full_action_name);
413 g_free (full_action_name);
414 gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
416 gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (priv->tree_view), NULL);
417 gtk_widget_show_all (menu);
418 gtk_menu_popup_at_pointer (GTK_MENU (menu), event);
422 treeview_button_press (GtkTreeView *treeview, GdkEvent *event,
426 GtkTreeView *tree_view = GTK_TREE_VIEW (priv->tree_view);
428 if (event->type == GDK_BUTTON_PRESS)
430 GdkEventButton *event_button = (GdkEventButton*)event;
431 if (event_button->button == GDK_BUTTON_SECONDARY)
433 GtkTreePath *path = NULL;
434 if (gtk_tree_view_get_path_at_pos (priv->tree_view, event_button->x, event_button->y,
435 &path, NULL, NULL, NULL))
437 GtkTreeSelection *selection = gtk_tree_view_get_selection (priv->tree_view);
439 if (!gtk_tree_selection_path_is_selected (selection, path))
441 gtk_tree_selection_unselect_all (selection);
442 gtk_tree_selection_select_path (selection, path);
445 gtk_tree_path_free (path);
447 treeview_popup (tree_view, event, page);
457 treeview_popup (treeview, NULL, page);
462 gnc_plugin_page_sx_list_create_widget (
GncPluginPage *plugin_page)
472 page = GNC_PLUGIN_PAGE_SX_LIST(plugin_page);
473 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
474 if (priv->widget != NULL)
480 widget = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
481 priv->widget = widget;
482 gtk_widget_show (priv->widget);
485 gtk_widget_set_name (GTK_WIDGET(priv->widget),
"gnc-id-sx-page");
488 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
489 gtk_box_set_homogeneous (GTK_BOX(vbox), FALSE);
490 gtk_paned_pack1 (GTK_PANED(widget), vbox, TRUE, FALSE);
492 label = gtk_label_new (_(
"Transactions"));
493 gnc_widget_style_context_add_class (GTK_WIDGET(label),
"gnc-class-strong");
494 gtk_widget_set_margin_start (GTK_WIDGET(label), 6);
495 gnc_label_set_alignment (label, 0.0, 0);
496 gtk_widget_show (label);
497 gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 0);
498 gtk_widget_show (vbox);
501 swin = gtk_scrolled_window_new (NULL, NULL);
502 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(swin),
503 GTK_POLICY_AUTOMATIC,
504 GTK_POLICY_AUTOMATIC);
505 gtk_box_pack_start (GTK_BOX(vbox), swin, TRUE, TRUE, 5);
506 gtk_widget_show (swin);
509 gtk_paned_set_position (GTK_PANED(priv->widget),
511 GNC_PREF_DIVIDER_POS));
515 g_date_clear (&end, 1);
517 g_date_add_years (&end, 1);
522 GAction *edit_action, *delete_action;
525 g_simple_action_set_enabled (G_SIMPLE_ACTION(edit_action), FALSE);
526 g_simple_action_set_enabled (G_SIMPLE_ACTION(delete_action), FALSE);
530 GtkTreeSelection *selection;
531 GtkTreePath *path = gtk_tree_path_new_first ();
533 priv->tree_view = GTK_TREE_VIEW(gnc_tree_view_sx_list_new (priv->instances));
534 g_object_set (G_OBJECT(priv->tree_view),
535 "state-section", STATE_SECTION,
536 "show-column-menu", TRUE,
538 gtk_container_add (GTK_CONTAINER( swin ), GTK_WIDGET(priv->tree_view));
540 selection = gtk_tree_view_get_selection (priv->tree_view);
541 gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
543 g_signal_connect (G_OBJECT(selection),
"changed", (GCallback)gppsl_selection_changed_cb, (gpointer)page);
544 g_signal_connect (G_OBJECT(priv->tree_view),
"row-activated", (GCallback)gppsl_row_activated_cb, (gpointer)page);
545 g_signal_connect (G_OBJECT(gtk_tree_view_get_model (GTK_TREE_VIEW(priv->tree_view))),
546 "model-populated", (GCallback)gppsl_model_populated_cb, (gpointer)page);
548 gtk_tree_selection_select_path (selection, path);
549 gtk_tree_path_free (path);
552 g_signal_connect (G_OBJECT(priv->tree_view),
"button-press-event",
553 G_CALLBACK(treeview_button_press), page);
554 g_signal_connect (G_OBJECT(priv->tree_view),
"popup-menu",
555 G_CALLBACK(treeview_popup_menu), page);
558 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
559 gtk_box_set_homogeneous (GTK_BOX(vbox), FALSE);
560 gtk_paned_pack2 (GTK_PANED(widget), vbox, TRUE, FALSE);
562 label = gtk_label_new (_(
"Upcoming Transactions"));
563 gnc_widget_style_context_add_class (GTK_WIDGET(label),
"gnc-class-strong");
564 gtk_widget_set_margin_start (GTK_WIDGET(label), 6);
565 gnc_label_set_alignment (label, 0.0, 0);
566 gtk_widget_show (label);
568 gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 0);
569 gtk_widget_show (vbox);
572 swin = gtk_scrolled_window_new (NULL, NULL);
573 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(swin),
574 GTK_POLICY_AUTOMATIC,
575 GTK_POLICY_AUTOMATIC);
576 gtk_box_pack_start (GTK_BOX(vbox), swin, TRUE, TRUE, 5);
577 gtk_widget_show (swin);
580 priv->dense_cal_model = gnc_sx_instance_dense_cal_adapter_new (GNC_SX_INSTANCE_MODEL(priv->instances));
581 priv->gdcal = GNC_DENSE_CAL(gnc_dense_cal_new_with_model (window, GNC_DENSE_CAL_MODEL(priv->dense_cal_model)));
582 g_object_ref_sink (priv->gdcal);
586 gnc_dense_cal_set_num_months (priv->gdcal, atoi (num_months));
589 gtk_container_add (GTK_CONTAINER(swin), GTK_WIDGET(priv->gdcal));
592 priv->gnc_component_id = gnc_register_gui_component (
"plugin-page-sx-list",
593 gnc_plugin_page_sx_list_refresh_cb,
594 gnc_plugin_page_sx_list_close_cb,
596 gnc_gui_component_set_session (priv->gnc_component_id,
597 gnc_get_current_session ());
599 g_signal_connect (G_OBJECT(plugin_page),
"inserted",
608 gnc_plugin_page_sx_list_destroy_widget (
GncPluginPage *plugin_page)
613 page = GNC_PLUGIN_PAGE_SX_LIST(plugin_page);
614 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
620 g_idle_remove_by_data (plugin_page);
624 g_object_unref (G_OBJECT(priv->widget));
628 if (priv->selected_list)
629 g_list_free (priv->selected_list);
631 if (priv->gnc_component_id)
633 gnc_unregister_gui_component (priv->gnc_component_id);
634 priv->gnc_component_id = 0;
647 gnc_plugin_page_sx_list_save_page (
GncPluginPage *plugin_page,
649 const gchar *group_name)
654 g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(plugin_page));
655 g_return_if_fail (key_file != NULL);
656 g_return_if_fail (group_name != NULL);
658 page = GNC_PLUGIN_PAGE_SX_LIST(plugin_page);
659 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
661 g_key_file_set_integer (key_file, group_name,
"dense_cal_num_months",
662 gnc_dense_cal_get_num_months (priv->gdcal));
664 g_key_file_set_integer (key_file, group_name,
"paned_position",
665 gtk_paned_get_position (GTK_PANED(priv->widget)));
678 gnc_plugin_page_sx_list_recreate_page (GtkWidget *window,
680 const gchar *group_name)
685 g_return_val_if_fail (key_file, NULL);
686 g_return_val_if_fail (group_name, NULL);
690 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
697 gint num_months = g_key_file_get_integer (key_file, group_name,
"dense_cal_num_months", &err);
699 gnc_dense_cal_set_num_months (priv->gdcal, num_months);
706 gint paned_position = g_key_file_get_integer (key_file, group_name,
707 "paned_position", &err);
709 gtk_paned_set_position (GTK_PANED(priv->widget), paned_position);
714 return GNC_PLUGIN_PAGE(page);
719 gnc_plugin_page_sx_list_cmd_new (GSimpleAction *simple,
723 auto plugin_page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
725 SchedXaction *new_sx;
726 gboolean new_sx_flag = TRUE;
734 g_date_clear (&now, 1);
736 recurrenceSet (r, 1, PERIOD_MONTH, &now, WEEKEND_ADJ_NONE);
738 schedule = g_list_append (schedule, r);
741 gnc_ui_scheduled_xaction_editor_dialog_create (window, new_sx, new_sx_flag);
742 gppsl_update_selected_list (plugin_page, TRUE, new_sx);
746 gnc_plugin_page_sx_list_cmd_refresh (GSimpleAction *simple,
750 auto plugin_page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
753 g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(plugin_page));
755 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(plugin_page);
756 gtk_widget_queue_draw (priv->widget);
760 gnc_plugin_page_sx_list_cmd_save_layout (GSimpleAction *simple,
764 auto plugin_page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
766 gchar *num_of_months;
769 g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(plugin_page));
771 priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(plugin_page);
773 num_of_months = g_strdup_printf (
"%d", gnc_dense_cal_get_num_months (priv->gdcal));
774 paned_position = gtk_paned_get_position (GTK_PANED(priv->widget));
782 g_free (num_of_months);
786 _edit_sx(gpointer data, gpointer user_data)
788 gnc_ui_scheduled_xaction_editor_dialog_create (GTK_WINDOW(user_data),
789 GNC_SCHEDXACTION(data), FALSE);
793 _argument_reorder_fn (GtkTreePath* list_path_data, GncTreeViewSxList* user_tree_view)
795 return gnc_tree_view_sx_list_get_sx_from_path (user_tree_view, list_path_data);
800 gnc_plugin_page_sx_list_cmd_edit (GSimpleAction *simple,
804 auto plugin_page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
807 GtkTreeSelection *selection;
808 GList *selected_paths, *to_edit;
811 selection = gtk_tree_view_get_selection (priv->tree_view);
812 selected_paths = gtk_tree_selection_get_selected_rows (selection, &model);
815 g_warning (
"no selection edit.");
820 (GncGMapFunc)_argument_reorder_fn,
823 gppsl_update_selected_list (plugin_page, TRUE, NULL);
824 for (GList *list = to_edit; list != NULL; list = list->next)
826 DEBUG (
"to-edit [%s]\n", xaccSchedXactionGetName (GNC_SCHEDXACTION(list->data)));
827 gppsl_update_selected_list (plugin_page, FALSE, GNC_SCHEDXACTION(list->data));
830 g_list_foreach (to_edit, (GFunc)_edit_sx, window);
831 g_list_free (to_edit);
832 g_list_foreach (selected_paths, (GFunc)gtk_tree_path_free, NULL);
833 g_list_free (selected_paths);
838 gnc_plugin_page_sx_list_cmd_edit_tax_options (GSimpleAction *simple,
842 auto plugin_page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
845 ENTER (
"(action %p, page %p)", simple, plugin_page);
846 gnc_tax_info_dialog (window, NULL);
852 gppsl_row_activated_cb (GtkTreeView *tree_view,
854 GtkTreeViewColumn *column,
861 SchedXaction *sx = gnc_tree_view_sx_list_get_sx_from_path (
862 GNC_TREE_VIEW_SX_LIST(priv->tree_view), path);
863 gnc_ui_scheduled_xaction_editor_dialog_create (window, sx, FALSE);
864 gppsl_update_selected_list (page, TRUE, sx);
869 _destroy_sx(gpointer data, gpointer user_data)
872 auto sx = GNC_SCHEDXACTION(data);
874 book = gnc_get_current_book ();
875 sxes = gnc_book_get_schedxactions (book);
876 gnc_sxes_del_sx (sxes, sx);
877 gnc_sx_begin_edit (sx);
883 _destroy_sx_names (gpointer data, gpointer user_data)
885 auto sx = GNC_SCHEDXACTION(data);
886 GList **to_delete_names = (GList**)user_data;
887 *to_delete_names = g_list_append (*to_delete_names, xaccSchedXactionGetName (sx));
892 gnc_plugin_page_sx_list_cmd_delete (GSimpleAction *simple,
896 auto plugin_page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
898 GtkTreeSelection *selection = gtk_tree_view_get_selection (priv->tree_view);
899 GList *selected_paths, *to_delete = NULL, *to_delete_names = NULL;
902 gchar *message = NULL;
904 gchar *text_list_of_scheduled_transaction_names = NULL;
906 selected_paths = gtk_tree_selection_get_selected_rows (selection, &model);
909 g_warning (
"no selection for delete.");
914 (GncGMapFunc)_argument_reorder_fn,
917 g_list_foreach (to_delete, (GFunc)_destroy_sx_names, &to_delete_names);
921 length = g_list_length (to_delete);
926 message = g_strdup_printf (
"%s\n\n%s",
927 ngettext (
"Do you really want to delete this scheduled transaction?",
928 "Do you really want to delete these scheduled transactions?",
930 text_list_of_scheduled_transaction_names);
932 g_free (text_list_of_scheduled_transaction_names);
933 g_list_free (to_delete_names);
935 if (gnc_verify_dialog (window, FALSE,
"%s", message))
937 gppsl_update_selected_list (plugin_page, TRUE, NULL);
938 for (GList *list = to_delete; list != NULL; list = list->next)
940 DEBUG(
"to-delete [%s]\n", xaccSchedXactionGetName (GNC_SCHEDXACTION(list->data)));
941 gppsl_update_selected_list (plugin_page, FALSE, GNC_SCHEDXACTION(list->data));
943 g_list_foreach (to_delete, (GFunc)_destroy_sx, NULL);
947 g_list_free (to_delete);
948 g_list_foreach (selected_paths, (GFunc)gtk_tree_path_free, NULL);
949 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.