aboutsummarylogtreecommitdiffstats
path: root/gtk_win.h
blob: b8f5110af4a527c2afdffa00185f1c649074e788 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef TICK_GTK_WIN_H
#define TICK_GTK_WIN_H

#include <gtk/gtk.h>
#include "portfolio.h"

typedef enum column_index {
    AMOUNT, SYMBOL, VALUE, SPENT, PROFIT, PROFIT_PERCENT, PROFIT_24H, PROFIT_24H_PERCENT, PROFIT_7D,
    PROFIT_7D_PERCENT, PROFIT_30D, PROFIT_30D_PERCENT, NUM_COLS
} Col_Index;

typedef struct app_data {
    Info_Array* portfolio_data;
    String* portfolio_string;
    GtkBuilder* builder;
    char password[PASS_MAX];
} App_Data;

/**
 * Opens GTK+ Window and prints portfolio data to it. Currently cannot handle encrypted portfolios.
 */
void window_main(void);

void check_list_create_from_string(void);

void check_list_add_api_data(void);

/** SIGNALS **/

void on_load_button_clicked(GtkButton* button);

void on_modify_button_clicked(GtkButton* button);

void on_modify_entry_activate(GtkEntry* entry, gpointer dialog);

void on_portfolio_modify_dialog_response(GtkDialog* dialog, gint response_id);

void on_password_entry_activate(GtkEntry* entry, gpointer dialog);

void on_get_password_dialog_response(GtkDialog* dialog, gint response_id, gpointer entry);

/**
 * Signal handler for destroying main window. Exits the program.
 */
void on_check_window_destroy(void);

/**
 * Signal handler for clicking column labels. Sorts the ListStore struct according to which
 * column was clicked.
 * @param column clicked column
 * @param list_store portfolio data list
 */
void on_column_clicked(GtkTreeViewColumn* column, GtkListStore* list_store);

/** UTILS **/

/**
 * Formats text in Info structs for printing to window
 * @param portfolio_data
 */
void format_cells(Info_Array* portfolio_data);

/**
 * Sorts a ListStore struct according to idx.
 * @param list_store ListStore to sort
 * @param idx column number
 */
void list_store_sort(GtkListStore* list_store, Col_Index idx);

void list_store_update(void);

#endif