Crate libhealth[][src]

Expand description

Health

Welcome to Heath’s docs! Health is a health tracking app for the GNOME desktop.

This documentation should help you get started with Health’s structs and functions. To make the start a bit easier, let me explain some basics about Health:

  • Health’s source is split into multiple directiories to make working with the many source files a bit easier:
    • core: This directory contains core modules of Health that are used throughout the application, like the Settings struct that’s used for retrieving GSettings values.
    • model: This directory contains the data types of Health. Things like Activity, which holds data about a single activity live here.
    • sync: The code for synching with third party providers (e.g. Google Fit) or exporting/importing data lies here.
    • views: This directory contains Views. These make up a single page in Health, e.g. the ViewSteps that draws a that draws a graph of the user’s step count.
    • widgets: Widgets are smaller, reusable parts of Health’s UI, e.g the BmiLevelBar is contained in this module.
    • windows: This directory contains actual windows, like the main Window or the PreferencesWindow.
  • Health has a rather strict code style to make sure working with the sourcecode is easy:
    • Please make sure cargo fmt and cargo clippy are happy with any changes you do. CI will also run these tests when creating new merge requests.
    • Please make sure your subclasses roughly follow this structure:
      mod my_struct {
          use gtk::glib::{subclass::prelude::*, self};
      
          // This is your struct to do GObject subclassing.
          // No additional logic should be implemented here.
          mod imp {
              use gtk::glib::{subclass::{self, prelude::*}, self};
      
              #[derive(Default, Debug)]
              pub struct MyStruct {}
      
              #[glib::object_subclass]
              impl ObjectSubclass for MyStruct {
                  const NAME: &'static str = "MyStruct";
                  type ParentType = glib::Object;
                  type Type = super::MyStruct;
      
              }
      
              impl ObjectImpl for MyStruct {}
          }
      
          // This is your public struct, that can be used in other modules / ui XML etc.
          glib::wrapper! {
              pub struct MyStruct(ObjectSubclass<imp::MyStruct>);
          }
      
          // Actual logic goes here.
          impl MyStruct {}
      }
    • Please sure to order functions in the following order to make it easy to find functions:
      • pub functions first, sorted alphabetically
      • private functions afterwards, also sorted alphabetically
    • Try only having one (public) GObject class per file and name the file after the public class. That way it’s easy to find classes in the folder structure.
    • Personally, I prefer to not use gtk and other GObject crates, but you do you.

Modules

i18n
utils

Macros

inner_refcell_getter_setter

Automatically generate generate getters&setters for members of the inner struct (where inner is a RefCell).

properties_setter_getter

Automatically implement Rust getters and setters for the property name of type type

refcell_getter_setter

Automatically generate getters&setters for the private struct’s inner RefCell

settings_getter_setter

Automatically generate helper functions for connecting to/getting/setting GSettings key

Structs

Activity

An Activity represents a single activity an user has performed (e.g. walking).

ActivityDataPoints

An ActivityDataPoints are different data points that an Activity can hold.

ActivityInfo

A struct containing informations about a certain activity type.

ActivityInfoBoxed
ActivityRow

An implementation of [gtk::ListBox] that displays infos about an Activity.

ActivityTypeRow

An implementation of [gtk::ListBoxRow] that is used in a ActivityTypeSelector and displays information about a single ActivityType.

ActivityTypeRowData

The data belonging to a certain ActivityTypeRow. This can be fed to a ActivityTypeRow via a [gio::ListModel].

ActivityTypeSelector

A widget for selecting an ActivityType (e.g. for adding a new activity).

Application

Application is an implementation of GtkApplication that handles starting & managing the windows etc.

Application

Application is an implementation of GioApplication that handles displaying of notifications.

Arrows

A View for visualizing the development of data over time.

BarGraphView

A View for visualizing the development of data over time.

BmiLevelBar

A widget to visualise the BMI of the user.

CircularProgressBar

A View for visualizing the development of data over time.

ColorCircle

A Widget for visualizing the color in legend table.

DataAddDialog

popup dialog box that adds activity/weight/water intake data .

Database

Helper class to add and retrieve data to and from the Tracker Database.

DateSelector

A widget to select a date via a [gtk::Calendar] or by entering a date into a [gtk::Entry].

DistanceActionRow

An implementation adw::ActionRow that contains a [gtk::SpinButton] and also allows switching between small&big units (e.g. kilometer vs meter) via a [gtk::ToggleButton].

ExportDialog

A dialog for exporting data

GraphModelCalories

A GraphModelCalories manages calories data for easy consumption in views.

GraphModelSteps

A GraphModelSteps manages step data for easy consumption in views.

GraphModelWeight

A GraphModelWeight manages weight data for easy consumption in views.

GraphView

A View for visualizing the development of data over time.

ImportDialog

A dialog for exporting data

LegendRow

LegendRow is a Widget that shows a colored circle next to the activity name.

ModelActivity

An implementation of [gio::ListModel] that stores Activitys. Can be used with ActivityView to display past activities.

ModelNotification

The data belonging to a certain ActivityTypeRow. This can be fed to a ActivityTypeRow via a [gio::ListModel].

PasswordEntry

The PasswordEntry is a adw::Bin where users enter passwords.

Point

A Point describes a single datapoint in a GraphView

PreferencesWindow

The PreferencesWindow is presented to the user to set certain settings in the application.

Settings
SetupWindow

The SetupWindow is shown to the user on the first start of the applcation to fill in some data.

SplitBar
Steps

A Steps is a single step measurement the user did on a certain date.

SyncListBox

The SyncListBox is a [gtk::ListBox] where users can initialise synching with a third-party provider.

TabButton

TabButton is a toplevel container that is implemented by all other views of Health.

Tuple

A Tuple describes a single segment in a BarGraphView

UnitSpinButton

A Widget for visualizing the color in legend table.

View

View is a toplevel container that is implemented by all other views of Health.

ViewActivity

An implementation of View visualizes activities the user recently did.

ViewAddActivity

A few widgets for adding a new activity record.

ViewAddWeight

A few widgets for adding a new weight record.

ViewCalories

An implementation of View visualizes calorie Spent records.

ViewHomePage

An implementation of View visualizes activities the user recently did.

ViewSteps

An implementation of View visualizes streak counts and daily step records.

ViewWeight

An implementation of View visualizes BMI and weight development.

Weight

A Weight is a single weight measurement the user did on a certain date.

Window

The toplevel application window that holds all other widgets.

Enums

ActivityType

All supported ActivityTypes are listed in this enum.

NotifyMode
UnitKind
UnitSystem
Unitsize

A Unitsize is so the user can choose to enter different unit sizes (e.g. km vs meter).

ViewMode
ViewPeriod

Traits

ViewExt
ViewImpl
ViewImplExt

Functions

i18n
i18n_f
i18n_k
ni18n
ni18n_f
ni18n_k
pi18n
pi18n_f
pi18n_k
pni18n
pni18n_f
pni18n_k

Type Definitions

PinnedResultFuture