Skip to content
API Documentation
BastionGuard™
MiscBox Class Reference
Inheritance diagram for MiscBox:

Public Member Functions

 MiscBox (Gtk.Window _parent_window, bool _restore_mode)
void refresh ()

Private Member Functions

void init_date_format_option (Gtk.Box box)

Private Attributes

Gtk.Window parent_window
bool restore_mode = false

Detailed Description

Definition at line 16 of file MiscBox.vala.

Constructor & Destructor Documentation

◆ MiscBox()

MiscBox.MiscBox ( Gtk.Window _parent_window,
bool _restore_mode )
inline

Definition at line 21 of file MiscBox.vala.

21 {
22
23 log_debug("MiscBox: MiscBox()");
24 GLib.Object(orientation: Gtk.Orientation.VERTICAL, spacing: 6);
25 parent_window = _parent_window;
26 margin_top = 12;
27 margin_bottom = 12;
28 margin_start = 12;
29 margin_end = 12;
30 restore_mode = _restore_mode;
32 refresh();
33 log_debug("MiscBox: MiscBox(): exit");
34 }
bool restore_mode
Definition MiscBox.vala:19
Gtk.Window parent_window
Definition MiscBox.vala:18
void init_date_format_option(Gtk.Box box)
Definition MiscBox.vala:36
void refresh()
Definition MiscBox.vala:98
void log_debug(string message)

References init_date_format_option(), TeeJee.Logging.log_debug(), parent_window, refresh(), and restore_mode.

Referenced by SettingsWindow.build_pages().

Member Function Documentation

◆ init_date_format_option()

void MiscBox.init_date_format_option ( Gtk.Box box)
inlineprivate

Definition at line 36 of file MiscBox.vala.

36 {
37
38 log_debug("MiscBox: init_date_format_option()");
39 add_label_header(box, _("Date Format"), false);
40
41 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
42 box.append(hbox);
43
44 var combo = new Gtk.ComboBoxText();
45 combo.hexpand = true;
46 hbox.append(combo);
47
48 var entry = new Gtk.Entry();
49 entry.hexpand = true;
50 hbox.append(entry);
51
52 var now = new DateTime.local(2019, 8, 11, 20, 25, 43);
53 string[] formats = {
54 "",
55 "%Y-%m-%d %H:%M:%S",
56 "%Y-%m-%d %I:%M %p",
57 "%d %b %Y %I:%M %p",
58 "%Y %b %d, %I:%M %p",
59 "%c"
60 };
61
62 int active = 0;
63 for (int i = 0; i < formats.length; i++){
64 string fmt = formats[i];
65 string preview = (fmt.length == 0) ? _("Custom") : now.format(fmt);
66 combo.append_text(preview);
67 if (App.date_format == fmt){
68 active = i;
69 }
70 }
71 combo.active = active;
72
73 combo.changed.connect(() => {
74 int idx = combo.get_active();
75 if ((idx < 0) || (idx >= formats.length)){
76 return;
77 }
78 string fmt = (formats[idx].length > 0) ? formats[idx] : Main.date_format_default;
79 entry.text = fmt;
80 entry.sensitive = (formats[idx].length == 0);
81 App.date_format = fmt;
82 });
83
84 entry.text = App.date_format;
85 entry.sensitive = (combo.get_active() == 0);
86
87 entry.notify["has-focus"].connect(() => {
88 if (!entry.has_focus){
89 App.date_format = entry.text;
90 log_debug("saved date_format: %s".printf(App.date_format));
91 }
92 });
93
94 show();
95 log_debug("MiscBox: init_date_format_option(): exit");
96 }
Main App
#define _(s)
string date_format
Definition Main.vala:130

References _, App, Main.date_format, Main.date_format_default, and TeeJee.Logging.log_debug().

Referenced by MiscBox().

◆ refresh()

void MiscBox.refresh ( )
inline

Definition at line 98 of file MiscBox.vala.

98 {
99 show();
100 }

Referenced by MiscBox().

Member Data Documentation

◆ parent_window

Gtk.Window MiscBox.parent_window
private

Definition at line 18 of file MiscBox.vala.

Referenced by MiscBox().

◆ restore_mode

bool MiscBox.restore_mode = false
private

Definition at line 19 of file MiscBox.vala.

Referenced by MiscBox().


The documentation for this class was generated from the following file:
  • BastionGuard/thirdparty/bastionguard-backup/src/Gtk/MiscBox.vala