Skip to content

Commit

Permalink
1.0.9 - Radical shift on the toolbar. Let's not overcharge the app.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lains committed Jun 6, 2017
1 parent 2bac08b commit 3ac1e74
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 192 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ![icon](data/icon.png) Notejot
## Stupidly simple jotting pad.
## Stupidly simple sticky notes applet.

![Screenshot](data/shot.png)

Expand Down
3 changes: 1 addition & 2 deletions data/com.github.lainsce.notejot.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
<name>Notejot</name>
<summary>Jot your ideas</summary>
<description>
<p>A stupidly-simple jotting pad for any type of short term notes.</p>
<p>A stupidly-simple sticky notes app for any type of short term notes.</p>
<ul>
<li>Save your notes anywhere, even on existing files.</li>
<li>Quit anytime with the shortcut Ctrl + Q</li>
</ul>
</description>
Expand Down
Binary file modified data/shot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
com.github.lainsce.notejot (1.0.9) xenial; urgency=low

* Removed the unnecessary open/save buttons or even file handling other then the tmp file.

-- Lains <[email protected]> Mon, 6 June 2017 02:45:00 -0300

com.github.lainsce.notejot (1.0.8) xenial; urgency=low

* Fixed the unnecessary higlighting of brackets.
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Standards-Version: 3.9.3
Package: com.github.lainsce.notejot
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: A stupidly-simple jotting pad.
Description: A stupidly-simple sticky notes app.
3 changes: 1 addition & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Name our project
project('com.github.lainsce.notejot', ['vala', 'c'],
version: '1.0.8'
version: '1.0.9'
)

# Import main lib files
Expand Down Expand Up @@ -43,7 +43,6 @@ executable(
'src/Constants/Stylesheet.vala',
'src/Constants/AppSettings.vala',
'src/Utils/FileUtils.vala',
'src/Utils/DialogUtils.vala',
c_args: c_args,
dependencies: [
dependency('granite'),
Expand Down
2 changes: 1 addition & 1 deletion src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Notejot {
app_years = "2017";
exec_name = "com.github.lainsce.notejot";
app_launcher = "com.github.lainsce.notejot";
build_version = "1.0.8";
build_version = "1.0.9";
app_icon = "com.github.lainsce.notejot";
main_url = "https://github.com/lainsce/notejot/";
bug_url = "https://github.com/lainsce/notejot/issues";
Expand Down
79 changes: 0 additions & 79 deletions src/Utils/DialogUtils.vala

This file was deleted.

4 changes: 2 additions & 2 deletions src/Utils/FileUtils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace Notejot.Utils.FileUtils {
private void save_tmp_file () {
if ( tmp_file.query_exists () ) {
try {
tmp_file.delete();
tmp_file.delete ();
} catch (Error e) {
error ("Error: %s\n", e.message);
}
Expand All @@ -70,6 +70,6 @@ namespace Notejot.Utils.FileUtils {
string buffer = Widgets.SourceView.buffer.get_text (start, end, true);
uint8[] binbuffer = buffer.data;

save_file(tmp_file, binbuffer);
save_file (tmp_file, binbuffer);
}
}
112 changes: 8 additions & 104 deletions src/Widgets/Toolbar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,124 +22,28 @@ using Granite;

namespace Notejot.Widgets {
public class Toolbar : Gtk.HeaderBar {
private Gtk.Button new_button;
private Gtk.Button open_button;
private Gtk.Button save_button;
private Gtk.Button clear_button;

public File file;

public Toolbar() {
public Toolbar () {
var header_context = this.get_style_context ();
header_context.add_class ("notejot-toolbar");

new_button = new Gtk.Button ();
new_button.set_image (new Gtk.Image.from_icon_name ("edit-delete-symbolic", Gtk.IconSize.SMALL_TOOLBAR));
new_button.has_tooltip = true;
new_button.tooltip_text = (_("Clear note"));
clear_button = new Gtk.Button ();
clear_button.set_image (new Gtk.Image.from_icon_name ("edit-delete-symbolic", Gtk.IconSize.SMALL_TOOLBAR));
clear_button.has_tooltip = true;
clear_button.tooltip_text = (_("Clear note"));

new_button.clicked.connect(() => {
clear_button.clicked.connect (() => {
Widgets.SourceView.buffer.set_text ("");
Utils.FileUtils.save_tmp_file ();
});

save_button = new Gtk.Button ();
save_button.set_image (new Gtk.Image.from_icon_name ("document-save-as-symbolic", Gtk.IconSize.SMALL_TOOLBAR));
save_button.has_tooltip = true;
save_button.tooltip_text = (_("Save as…"));

save_button.clicked.connect(() => {
save_button_pressed ();
});

open_button = new Gtk.Button ();
open_button.set_image (new Gtk.Image.from_icon_name ("document-open-symbolic", Gtk.IconSize.SMALL_TOOLBAR));
open_button.has_tooltip = true;
open_button.tooltip_text = (_("Open…"));

open_button.clicked.connect(() => {
open_button_pressed ();
});

this.pack_start (new_button);
this.pack_end (save_button);
this.pack_end (open_button);
this.pack_end (clear_button);

this.show_close_button = true;
this.show_all ();
}

public void open_button_pressed () {
debug ("Open button pressed.");

if (Widgets.SourceView.is_modified = true) {
try {
debug ("Opening file...");
open_document ();
} catch (Error e) {
error ("Unexpected error during open: " + e.message);
}
}

file = null;
Widgets.SourceView.is_modified = false;
}

public void save_button_pressed () {
debug ("Save button pressed.");

if (Widgets.SourceView.is_modified = true) {
try {
debug ("Saving file...");
save_document ();
} catch (Error e) {
error ("Unexpected error during save: " + e.message);
}
}

file = null;
Widgets.SourceView.is_modified = false;
}

public bool open_document () throws Error {
// If it's a file, ask the user for a valid location.
if (file == null) {
debug ("Asking the user what to open.");
file = Utils.DialogUtils.display_open_dialog ();
// If file is still null, then user aborted open operation.
if (file == null) {
debug ("User cancelled operation. Aborting.");
return false;
}
}

string text;
FileUtils.get_contents (file.get_path(), out text);

Widgets.SourceView.buffer.text = text;
return true;
}

public bool save_document () throws Error {
// If it's a new file, ask the user for a valid location.
if (file == null) {
debug ("Asking the user where to save.");
file = Utils.DialogUtils.display_save_dialog ();
// If file is still null, then user aborted save operation.
if (file == null) {
debug ("User cancelled operation. Aborting.");
return false;
}
}

if (file.query_exists ())
file.delete ();

Gtk.TextIter start, end;
Widgets.SourceView.buffer.get_bounds (out start, out end);
string buffer = Widgets.SourceView.buffer.get_text (start, end, true);
uint8[] binbuffer = buffer.data;
Utils.FileUtils.save_file (file, binbuffer);
return true;
}
}
}

0 comments on commit 3ac1e74

Please sign in to comment.