#pragma once

#include <gtk/gtk.h>
#ifdef ENABLE_MINIMIZE_TO_TRAY
#include <libayatana-appindicator/app-indicator.h>
#endif
#include <jansson.h>
#include "../common/db-common.h"

#define DBUS_SERVICES 4

G_BEGIN_DECLS

typedef struct app_data_t {
    /* Non-owning references to the builders held by OtpclientWindow.
     * Do NOT g_object_unref() these — the window's dispose handles that. */
    GtkBuilder *builder;
    GtkBuilder *add_popover_builder;
    GtkBuilder *settings_popover_builder;

    GtkWidget *main_window;
    GtkTreeView *tree_view;
    GtkListStore *list_store;
    GtkTreeModelFilter *filter_model;
    GtkWidget *search_entry;
    GtkWidget *list_stack;
    #ifdef ENABLE_MINIMIZE_TO_TRAY
    AppIndicator *indicator;
    #endif

    GtkClipboard *clipboard;

    gboolean show_next_otp;
    gboolean disable_notifications;
    gboolean show_validity_seconds;
    GdkRGBA validity_color;
    GdkRGBA validity_warning_color;
    gboolean auto_lock;
    gint inactivity_timeout;

    GtkCssProvider *delbtn_css_provider;
    GtkCssProvider *tv_css_provider;

    GNotification *notification;

    guint source_id;
    guint source_id_last_activity;

    DatabaseData *db_data;

    GDBusConnection *connection;
    guint subscription_ids[DBUS_SERVICES];

    gboolean app_locked;

    gboolean use_dark_theme;

    gboolean is_reorder_active;

    gboolean use_secret_service;

    gboolean use_tray;

    GDateTime *last_user_activity;

    gboolean search_provider_enabled;

    GtkWidget *diag_rcdb;
    GtkFileChooserAction open_db_file_action;

    gint window_width;
    gint window_height;
} AppData;


typedef struct node_info_t {
    guint hash;
    guint newpos;
} NodeInfo;

G_END_DECLS
