Skip to content

Commit

Permalink
Allow saving the sorting in the SLR
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob-IT committed Nov 20, 2023
1 parent 3deb494 commit 71feea0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
23 changes: 22 additions & 1 deletion gnucash/gnome/dialog-sx-since-last-run.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ G_GNUC_UNUSED static QofLogModule log_module = GNC_MOD_GUI_SX;

#define DIALOG_SX_SINCE_LAST_RUN_CM_CLASS "dialog-sx-since-last-run"

#define GNC_PREF_SET_REVIEW "review-transactions"
#define GNC_PREF_SLR_SORT_COL "sort-column"
#define GNC_PREF_SLR_SORT_ASC "sort-ascending"

struct _GncSxSinceLastRunDialog
{
GtkWidget *dialog;
Expand Down Expand Up @@ -1092,8 +1096,11 @@ gnc_ui_sx_since_last_run_dialog (GtkWindow *parent, GncSxInstanceModel *sx_insta
g_object_unref (sort_model);

/* default sort order */
gboolean sort_ascending = gnc_prefs_get_bool (GNC_PREFS_GROUP_STARTUP, GNC_PREF_SLR_SORT_ASC);
gint sort_column = gnc_prefs_get_int (GNC_PREFS_GROUP_STARTUP, GNC_PREF_SLR_SORT_COL);
GtkSortType sort_type = sort_ascending ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING;
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(sort_model),
SLR_MODEL_COL_NAME, GTK_SORT_ASCENDING);
sort_column, sort_type);

renderer = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes (_("Transaction"), renderer,
Expand Down Expand Up @@ -1215,6 +1222,20 @@ static void
close_handler (gpointer user_data)
{
GncSxSinceLastRunDialog *app_dialog = user_data;
GtkSortType order;
gint column;

if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE(
gtk_tree_view_get_model (app_dialog->instance_view)),
&column, &order))
{
gboolean sort_ascending = TRUE;
if (order == GTK_SORT_DESCENDING)
sort_ascending = FALSE;

gnc_prefs_set_bool (GNC_PREFS_GROUP_STARTUP, GNC_PREF_SLR_SORT_ASC, sort_ascending);
gnc_prefs_set_int (GNC_PREFS_GROUP_STARTUP, GNC_PREF_SLR_SORT_COL, column);
}

gnc_save_window_size (GNC_PREFS_GROUP_STARTUP, GTK_WINDOW(app_dialog->dialog));
gtk_widget_destroy (app_dialog->dialog);
Expand Down
1 change: 0 additions & 1 deletion gnucash/gnome/dialog-sx-since-last-run.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#define GNC_PREFS_GROUP_STARTUP "dialogs.sxs.since-last-run"
#define GNC_PREF_RUN_AT_FOPEN "show-at-file-open"
#define GNC_PREF_SHOW_AT_FOPEN "show-notify-window-at-file-open"
#define GNC_PREF_SET_REVIEW "review-transactions"

typedef struct _GncSxSlrTreeModelAdapter GncSxSlrTreeModelAdapter;
typedef struct _GncSxSinceLastRunDialog GncSxSinceLastRunDialog;
Expand Down
11 changes: 10 additions & 1 deletion gnucash/gschemas/org.gnucash.GnuCash.dialogs.sxs.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,17 @@
<summary>Set "Review Created Transactions" as the default for the "since last run" dialog.</summary>
<description>This setting controls whether as default the "review created transactions" is set for the "since last run" dialog.</description>
</key>
<key name="sort-column" type="i">
<default>0</default>
<summary>Set the sort column in the "since last run" dialog.</summary>
<description>This settings sets the sort column in the "since last run" dialog.</description>
</key>
<key name="sort-ascending" type="b">
<default>true</default>
<summary>Set the sort direction in the "since last run" dialog.</summary>
<description>This settings sets the sort direction in the "since last run" dialog.</description>
</key>
</schema>

<schema id="org.gnucash.GnuCash.dialogs.sxs.transaction-editor" path="/org/gnucash/GnuCash/dialogs/scheduled-trans/transaction-editor/">
<key name="create-auto" type="b">
<default>false</default>
Expand Down

0 comments on commit 71feea0

Please sign in to comment.