Skip to content

Add date/time label#263

Closed
aljelly wants to merge 8 commits intoPhilip-Scott:page-list-upgradefrom
aljelly:preview-date
Closed

Add date/time label#263
aljelly wants to merge 8 commits intoPhilip-Scott:page-list-upgradefrom
aljelly:preview-date

Conversation

@aljelly
Copy link
Copy Markdown

@aljelly aljelly commented Mar 17, 2018

Fixes #257

Changes made in this pull request:

  • Show date/time in page list
  • Page list now sorts by modified
  • Uses system time format (12h or 24h)

This is just the functionality, there's another branch coming that improves the look.

Preview of this PR (not the improved style PR):

image

@aljelly aljelly requested a review from Philip-Scott as a code owner March 17, 2018 07:14
Copy link
Copy Markdown
Owner

@Philip-Scott Philip-Scott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey man! First of all, thank you so much for your contribution! Seeing new people interested in contributing to my little app always makes me happy :)

I've left a couple of change requests as comments. Nothing mayor, but i left references to help you out on the ones that require a bit more work :)

I'm also not merging this branch to master just yet, but to a separate branch i've made to catch all the upcoming changes to the pages list while we work on them (also made a milestone to track said changes! https://github.com/Philip-Scott/Notes-up/milestone/5)

If you have any questions, don't be afraid to ask! Thanks again :)

Comment thread src/Services/ClockSettings.vala Outdated
with this program. If not, see <http://www.gnu.org/licenses/>
END LICENSE
***/
public class ClockSettings : Granite.Services.Settings {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're only going to be fetching one property from this settings page, instead of making a new class just for it you should use GLib.Settings :) It will also allow you to "bind" to the property so changes are updated at creation time

Note: For this to work, the use_24_format bool should be changed to a "property" use24HSFormat { get; set; }

Comment thread src/Application.vala Outdated
namespace ENotes {
public ENotes.Services.Settings settings;
public ENotes.Window window;
public ClockSettings clockSettings;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two comments :)

  • In vala, variable names use are named_like_this
  • Change to private since clock_settings is not in use in any other place

For more about code style, check this: https://elementary.io/docs/code/reference#variable-names-class-names-function-names

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw that the variable names were like this from the time indicator.... our bad... We've learned a lot from the past few years! 😅

Comment thread src/Application.vala Outdated
settings = ENotes.Services.Settings.get_instance ();

clockSettings = new ClockSettings ();
use24HSFormat = (clockSettings.clock_format == "24h");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we will be now "depending" on a settings schema that we don't include, you need to first validate that it exists, if not it will fail :)

See this code for how it's done: https://github.com/elementary/wingpanel-indicator-nightlight/blob/master/src/Indicator.vala#L106

Comment thread src/Widgets/PageItem.vala Outdated
private Gtk.Grid grid;
private Gtk.Label line1;
private Gtk.Label line2;
private Gtk.Label line3;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it should be changed for "date_line"? what do you think? :)

Comment thread src/Widgets/PageItem.vala Outdated
time = new DateTime.from_unix_utc (page.modification_date);

if (use24HSFormat) {
date_string = time.format ("%H:%M, %a, %e %b %Y");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • You should use the same format that you did on your mockup :)
    • EG: Saturday, May 17, 2018, 9:26
  • Make the string translatable: surround the string within _("")

Comment thread src/Widgets/PagesList.vala Outdated
int64 a = ((PageItem) row1).page.id;
int64 b = ((PageItem) row2).page.id;
int64 a = ((PageItem) row1).page.modification_date;
int64 b = ((PageItem) row2).page.modification_date;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, leave the sorting as by page.id. This will make sure that the changes won't affect other users, and we can change said sorting by later implementing #118 on a different PR :)

Comment thread src/Widgets/PagesList.vala Outdated
if (b > a) return 1;

return 0;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't leave commented code ;)

Comment thread src/Widgets/PagesList.vala Outdated
var page_item = added_pages.get ((int) page.id);
page_item.page = page;
page_item.load_data ();
listbox.invalidate_sort ();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're removing the page sorting change from this PR, this shouldn't be needed for now :)

@Philip-Scott Philip-Scott changed the base branch from master to page-list-upgrade March 17, 2018 15:51
@aljelly
Copy link
Copy Markdown
Author

aljelly commented Mar 18, 2018

I addressed all except your first review comment; I'm not sure how to access the clock_format property or if I'm even setting it up correctly.

Also I gave all the line variables better names at the same time as renaming the line3 label.

I pushed the new changes, could you have a look?

(The app builds and runs but the date label currently just shows "placeholder". The new commented out code is temporary and just there until I can get clock_format working, I'll remove it after)

@Philip-Scott
Copy link
Copy Markdown
Owner

Check More closely how the code for the indicator I sent you worked :) all you need to get from the interface is the bool value for is_24_hours (unsure what the actual name is) and store that in the app :)

I'm not currently home, but if you want I can help you tomorrow with it

@Philip-Scott
Copy link
Copy Markdown
Owner

I'm closing this in favor of the new style i'm adding in version 2.0.0, where the created/modified date is shown in the new PageInfo Toolbar

image

Sorry for not merging this, but thank you still for your contribution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants