Skip to content

Commit

Permalink
* - UI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lains committed Sep 10, 2021
1 parent 3084095 commit ed633d7
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 104 deletions.
5 changes: 0 additions & 5 deletions data/io.github.lainsce.Khronos.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,5 @@
<default>false</default>
<summary>Whether the UI is in Dark Mode or not</summary>
</key>
<key name="sort-type" type="s">
<default>'time'</default>
<summary>Sorting type for the task list</summary>
<description>The user-preferred sorting of tasks to use in Khronos, default is time</description>
</key>
</schema>
</schemalist>
3 changes: 1 addition & 2 deletions data/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
headerbar {
background-image: none;
background: @theme_bg_color;
border-bottom: 1px solid @borders;
}

headerbar.flat {
border-bottom: 2px solid @borders;
border-bottom: 1px solid @borders;
}

.kh-title {
Expand Down
2 changes: 2 additions & 0 deletions data/ui/logrow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</binding>
<style>
<class name="title"/>
<class name="numeric"/>
</style>
</object>
</child>
Expand All @@ -39,6 +40,7 @@
</binding>
<style>
<class name="subtitle"/>
<class name="numeric"/>
</style>
</object>
</child>
Expand Down
90 changes: 24 additions & 66 deletions data/ui/main_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,81 +7,38 @@
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="AdwViewStack" id="title_stack">
<property name="visible-child-name">main_title</property>
<child>
<object class="AdwViewStackPage" id="main_title">
<property name="name">main_title</property>
<property name="child">
<object class="AdwHeaderBar" id="timer_header">
<child type="title">
<object class="AdwViewSwitcher" id="win_switcher">
<property name="stack">win_stack</property>
</object>
</child>
<child type="end">
<object class="GtkMenuButton" id="menu_button">
<property name="can-focus">True</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
</child>
<style>
<class name="flat"/>
</style>
</object>
</property>
<object class="AdwHeaderBar" id="timer_header">
<child type="title">
<object class="AdwViewSwitcher" id="win_switcher">
<property name="stack">win_stack</property>
<property name="policy">wide</property>
</object>
</child>
<child>
<object class="AdwViewStackPage" id="logs_title">
<property name="name">logs_title</property>
<property name="child">
<object class="AdwHeaderBar" id="list_header">
<child type="title">
<object class="AdwViewSwitcher" id="win_switcher2">
<property name="stack">win_stack</property>
</object>
</child>
<child type="end">
<object class="GtkMenuButton" id="menu_button2">
<property name="can-focus">True</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
</child>
<child type="end">
<object class="GtkButton" id="export_button">
<property name="icon-name">document-send-symbolic</property>
<property name="tooltip-text" translatable="yes">Export logs as CSV…</property>
<property name="action-name">win.export</property>
<style>
<class name="image-button"/>
</style>
</object>
</child>
<child type="start">
<object class="GtkButton" id="trash_button">
<property name="can-focus">True</property>
<property name="icon-name">user-trash-symbolic</property>
<property name="tooltip-text" translatable="yes">Removes all logs from the list</property>
<style>
<class name="image-button"/>
<class name="destructive-action"/>
</style>
</object>
</child>
<style>
<class name="flat"/>
</style>
</object>
</property>
<child type="end">
<object class="GtkMenuButton" id="menu_button">
<property name="can-focus">True</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
</child>
<child type="start">
<object class="GtkButton" id="trash_button">
<property name="can-focus">True</property>
<property name="icon-name">user-trash-symbolic</property>
<property name="tooltip-text" translatable="yes">Removes all logs from the list</property>
<style>
<class name="image-button"/>
<class name="destructive-action"/>
</style>
</object>
</child>
<style>
<class name="flat"/>
</style>
</object>
</child>
<child>
<object class="AdwViewStack" id="win_stack">
<property name="vexpand">1</property>
<property name="visible-child-name">main</property>
<child>
<object class="AdwViewStackPage" id="main">
<property name="name">main</property>
Expand All @@ -99,6 +56,7 @@
<property name="margin-bottom">12</property>
<style>
<class name="kh-title"/>
<class name="numeric"/>
</style>
</object>
</child>
Expand Down
6 changes: 6 additions & 0 deletions data/ui/mainmenu.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<interface>
<menu id="menu">
<section>
<item>
<attribute name="label" translatable="yes">Export Logs as CSV…</attribute>
<attribute name="action">win.export</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Preferences</attribute>
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('io.github.lainsce.Khronos', ['vala', 'c'], version: '3.5.2')
project('io.github.lainsce.Khronos', ['vala', 'c'], version: '3.5.3')
gnome = import('gnome')
i18n = import('i18n')

Expand Down
50 changes: 20 additions & 30 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,8 @@ namespace Khronos {
[GtkChild]
public unowned Gtk.Button trash_button;
[GtkChild]
public unowned Gtk.MenuButton menu_button2;
[GtkChild]
public unowned Adw.ViewSwitcher win_switcher;
[GtkChild]
public unowned Adw.ViewSwitcher win_switcher2;
[GtkChild]
public unowned Adw.ViewStack title_stack;
[GtkChild]
public unowned Adw.ViewStack win_stack;
[GtkChild]
public unowned Gtk.Box placeholder;
Expand Down Expand Up @@ -133,9 +127,7 @@ namespace Khronos {

column.bind_model (liststore, item => make_widgets (item));

placeholder.set_visible (false);

column_time_label.set_label ("<span font_features='tnum'>%02u%02u%02u</span>".printf(hrs, min, sec));
column_time_label.set_label ("%02u%02u%02u".printf(hrs, min, sec));

column.row_activated.connect ((actrow) => {
var row = ((LogRow)column.get_selected_row ());
Expand All @@ -147,14 +139,13 @@ namespace Khronos {
var log = new Log ();
log.name = column_entry.text;
log.timedate = "%s\n%s%s".printf(column_time_label.label,
("<span font_features='tnum'>%s</span>").printf (dt.format ("%a, %d/%m %H%M%S")),
("<span font_features='tnum'>%s</span>").printf (dt.add_full (0,
0,
0,
(int)hrs,
(int)min,
(int)sec)
.format ("%H%M%S")));
("%s").printf (dt.format ("%a, %d/%m %H%M%S")),
("%s").printf (dt.add_full (0,
0,
0,
(int)hrs,
(int)min,
(int)sec).format ("%H%M%S")));

liststore.append (log);
tm.save_to_file (liststore);
Expand Down Expand Up @@ -199,17 +190,17 @@ namespace Khronos {
column.unselect_all ();
});

trash_button.visible = false;
win_stack.notify["visible-child-name"].connect (() => {
if (win_stack.get_visible_child_name () == "main") {
title_stack.set_visible_child_name ("main_title");
trash_button.visible = false;
} else {
title_stack.set_visible_child_name ("logs_title");
trash_button.visible = true;
}
});

var builder = new Gtk.Builder.from_resource ("/io/github/lainsce/Khronos/mainmenu.ui");
menu_button.menu_model = (MenuModel)builder.get_object ("menu");
menu_button2.menu_model = (MenuModel)builder.get_object ("menu");

trash_button.clicked.connect (() => {
var flags = Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL;
Expand Down Expand Up @@ -248,19 +239,18 @@ namespace Khronos {
});

tm.load_from_file ();

this.set_size_request (360, 360);
this.show ();
this.present ();

set_timeouts ();
liststore.items_changed.connect (() => {
tm.save_to_file (liststore);

if (liststore.get_n_items () == 0) {
placeholder.set_visible (false);
placeholder.set_visible (true);
}
});

this.set_size_request (360, 360);
this.show ();
this.present ();
}

public LogRow make_widgets (GLib.Object item) {
Expand All @@ -271,7 +261,7 @@ namespace Khronos {
sec = 0;
min = 0;
hrs = 0;
column_time_label.label = "<span font_features='tnum'>%02u%02u%02u</span>".printf(hrs, min, sec);
column_time_label.label = "%02u%02u%02u".printf(hrs, min, sec);
add_log_button.sensitive = false;
timer_button.sensitive = true;
column_entry.text = "";
Expand All @@ -288,15 +278,15 @@ namespace Khronos {
public void timer () {
if (start) {
sec += 1;
column_time_label.label = "<span font_features='tnum'>%02u%02u%02u</span>".printf(hrs, min, sec);
column_time_label.label = "%02u%02u%02u".printf(hrs, min, sec);
if (sec >= 60) {
sec = 0;
min += 1;
column_time_label.label = "<span font_features='tnum'>%02u%02u%02u</span>".printf(hrs, min, sec);
column_time_label.label = "%02u%02u%02u".printf(hrs, min, sec);
if (min >= 60) {
min = 0;
hrs += 1;
column_time_label.label = "<span font_features='tnum'>%02u%02u%02u</span>".printf(hrs, min, sec);
column_time_label.label = "%02u%02u%02u".printf(hrs, min, sec);
}
}
}
Expand Down

0 comments on commit ed633d7

Please sign in to comment.