Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 committed May 31, 2024
1 parent d858519 commit c5b05c9
Show file tree
Hide file tree
Showing 22 changed files with 208 additions and 55 deletions.
1 change: 1 addition & 0 deletions config.vala.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ namespace Build {
public const string DATADIR = @DATADIR@;
public const string PROFILE = @PROFILE@;
public const string LOCALEDIR = @LOCALEDIR@;
public const string GNOMELOCALEDIR = @GNOMELOCALEDIR@;
}
1 change: 0 additions & 1 deletion core/Objects/Project.vala
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ public class Objects.Project : Objects.BaseObject {
public signal void loading_changed (bool value);
public signal void project_count_updated ();
public signal void show_multi_select_change ();
public signal void expand_all_items (bool value);

construct {
deleted.connect (() => {
Expand Down
37 changes: 19 additions & 18 deletions core/QuickAdd.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ public class Layouts.QuickAdd : Adw.Bin {

private Gtk.Entry content_entry;
private Widgets.LoadingButton submit_button;
private Widgets.HyperTextView description_textview;
private Widgets.Markdown.Buffer current_buffer;
private Widgets.Markdown.EditView markdown_edit_view;
private Widgets.ItemLabels item_labels;
private Widgets.ProjectPicker.ProjectPickerButton project_picker_button;
private Widgets.ScheduleButton schedule_button;
Expand Down Expand Up @@ -75,16 +76,16 @@ public class Layouts.QuickAdd : Adw.Bin {

content_box.append (content_entry);

description_textview = new Widgets.HyperTextView (_("Add a description…")) {
height_request = 64,
current_buffer = new Widgets.Markdown.Buffer ();

markdown_edit_view = new Widgets.Markdown.EditView () {
left_margin = 14,
right_margin = 6,
top_margin = 6,
wrap_mode = Gtk.WrapMode.WORD_CHAR,
hexpand = true
connect_typing = false
};

description_textview.remove_css_class ("view");
markdown_edit_view.buffer = current_buffer;

item_labels = new Widgets.ItemLabels (item) {
margin_start = 6,
Expand Down Expand Up @@ -127,7 +128,7 @@ public class Layouts.QuickAdd : Adw.Bin {
quick_add_content.add_css_class ("card");
quick_add_content.add_css_class ("sidebar-card");
quick_add_content.append (content_box);
quick_add_content.append (description_textview);
quick_add_content.append (markdown_edit_view);
quick_add_content.append (item_labels);
quick_add_content.append (action_box);

Expand Down Expand Up @@ -280,15 +281,15 @@ public class Layouts.QuickAdd : Adw.Bin {
return false;
});

var description_controller_key = new Gtk.EventControllerKey ();
description_textview.add_controller (description_controller_key);
description_controller_key.key_pressed.connect ((keyval, keycode, state) => {
if ((ctrl_pressed || shift_pressed) && keyval == 65293) {
add_item ();
}
// var description_controller_key = new Gtk.EventControllerKey ();
// description_textview.add_controller (description_controller_key);
// description_controller_key.key_pressed.connect ((keyval, keycode, state) => {
// if ((ctrl_pressed || shift_pressed) && keyval == 65293) {
// add_item ();
// }

return false;
});
// return false;
// });

var event_controller_key = new Gtk.EventControllerKey ();
((Gtk.Widget) this).add_controller (event_controller_key);
Expand Down Expand Up @@ -330,7 +331,7 @@ public class Layouts.QuickAdd : Adw.Bin {
}

item.content = content_entry.get_text ();
item.description = description_textview.get_text ();
item.description = current_buffer.get_all_text ().chomp ();

if (item.project.backend_type == BackendType.LOCAL) {
item.id = Util.get_default ().generate_id ();
Expand Down Expand Up @@ -380,7 +381,7 @@ public class Layouts.QuickAdd : Adw.Bin {
reset_item ();

content_entry.text = "";
description_textview.set_text ("");
current_buffer.set_text ("");
schedule_button.reset ();
priority_button.reset ();
pin_button.reset ();
Expand Down
15 changes: 15 additions & 0 deletions core/Services/Database.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,21 @@ public class Services.Database : GLib.Object {
}
}

public Gee.ArrayList<Objects.Item> get_items_no_parent (bool checked = true) {
Gee.ArrayList<Objects.Item> return_value = new Gee.ArrayList<Objects.Item> ();
lock (_items) {
foreach (Objects.Item item in items) {
if (!item.was_archived () &&
item.checked == checked &&
!item.has_parent) {
return_value.add (item);
}
}

return return_value;
}
}

public bool valid_item_by_date (Objects.Item item, GLib.DateTime date, bool checked = true) {
if (!item.has_due || item.was_archived ()) {
return false;
Expand Down
1 change: 1 addition & 0 deletions core/Services/EventBus.vala
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class Services.EventBus : Object {
public signal void section_sort_order_changed (string project_id);
public signal void request_escape ();
public signal void drag_n_drop_active (string project_id, bool active);
public signal void expand_all (string project_id, bool active);

public bool _mobile_mode = Services.Settings.get_default ().settings.get_boolean ("mobile-mode");
public bool mobile_mode {
Expand Down
9 changes: 8 additions & 1 deletion core/Widgets/DateTimePicker/ScheduleButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class Widgets.ScheduleButton : Gtk.Grid {
private Gtk.Box schedule_box;
private Gtk.Image due_image;
private Widgets.DateTimePicker.DateTimePicker datetime_picker;
private Gtk.Revealer clear_revealer;

private GLib.DateTime _datetime;
public GLib.DateTime datetime {
Expand All @@ -52,6 +53,12 @@ public class Widgets.ScheduleButton : Gtk.Grid {
}
}

public bool visible_clear_button {
set {
clear_revealer.visible = value;
}
}

public signal void date_changed (GLib.DateTime? date);

public ScheduleButton () {
Expand Down Expand Up @@ -103,7 +110,7 @@ public class Widgets.ScheduleButton : Gtk.Grid {
css_classes = { "flat" }
};

var clear_revealer = new Gtk.Revealer () {
clear_revealer = new Gtk.Revealer () {
transition_type = Gtk.RevealerTransitionType.CROSSFADE,
child = clear_button
};
Expand Down
12 changes: 7 additions & 5 deletions core/Widgets/Markdown/MarkdownEditView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* https://github.com/toolstack/Folio
*/

public class Widgets.Markdown.EditView : Adw.Bin {
public class Widgets.Markdown.EditView : Adw.Bin {
public bool text_mode {
set {
markdown_view.text_mode = value;
Expand Down Expand Up @@ -68,12 +68,13 @@
}
}

public bool connect_typing { get; set; default = false; }

private Widgets.Markdown.View markdown_view;

private bool is_ctrl = false;

public bool is_editable { get; set; }

public signal void enter ();
public signal void leave ();
public signal void changed ();
Expand Down Expand Up @@ -166,7 +167,6 @@

var gesture = new Gtk.EventControllerFocus ();
markdown_view.add_controller (gesture);

gesture.enter.connect (handle_focus_in);
gesture.leave.connect (update_on_leave);

Expand All @@ -190,8 +190,10 @@
}

public void update_on_leave () {
Services.EventBus.get_default ().connect_typing_accel ();
leave ();
if (connect_typing) {
Services.EventBus.get_default ().connect_typing_accel ();
leave ();
}
}

public void on_dark_changed (bool dark) {
Expand Down
3 changes: 3 additions & 0 deletions data/io.github.alainm23.planify.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[D-BUS Service]
Name=@app_id@
Exec=@bindir@/@app_id@ --gapplication-service
10 changes: 10 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,14 @@ install_data('markdownpp.lang',
install_dir: get_option('datadir') / 'gtksourceview-5' / 'language-specs'
)

# service_conf = configuration_data()
# service_conf.set('appid', application_id)
# service_conf.set('bindir', bindir)
# configure_file(
# input: 'io.github.alainm23.planify.service.in',
# output: '@[email protected]'.format(application_id),
# configuration: service_conf,
# install_dir: datadir / 'dbus-1' / 'services'
# )

subdir('icons')
17 changes: 13 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(
'io.github.alainm23.planify',
'vala', 'c',
version: '4.7.6'
version: '4.8'
)

gnome = import('gnome')
Expand Down Expand Up @@ -51,23 +51,31 @@ if profile == 'development'
rev_txt = run_command('git','rev-parse','--short','HEAD').stdout().strip()
rev = '-@0@'.format(rev_txt)
application_id = 'io.github.alainm23.planify.Devel'
application_path = '/io/github/alainm23/planify/Devel'
else
rev = ''
application_id = 'io.github.alainm23.planify'
application_path = '/io/github/alainm23/planify'
endif

############
# Config #
############
prefix = get_option('prefix')
bindir = prefix / get_option('bindir')
datadir = prefix / get_option('datadir')
localedir = prefix / get_option ('localedir')
libexecdir = prefix / get_option('libexecdir')

conf_data = configuration_data()
conf_data.set_quoted('APPLICATION_ID', application_id)
conf_data.set_quoted('GETTEXT_PACKAGE', application_id)
conf_data.set_quoted('GNOMELOCALEDIR', localedir)
conf_data.set_quoted('VERSION', meson.project_version())
conf_data.set_quoted('LOCALEDIR', get_option('prefix') / get_option('localedir'))
conf_data.set_quoted('LOCALEDIR', localedir)
conf_data.set_quoted('PACKAGE_VERSION', meson.project_version())
conf_data.set_quoted('PREFIX', get_option('prefix'))
conf_data.set_quoted('DATADIR', join_paths (get_option('prefix'), get_option('datadir')))
conf_data.set_quoted('PREFIX', prefix)
conf_data.set_quoted('DATADIR', datadir)
conf_data.set_quoted('PROFILE', profile)

config_file = configure_file(
Expand All @@ -80,6 +88,7 @@ subdir('core')
subdir('src')
subdir('quick-add')
subdir('data')
# subdir('search-provider')
subdir('po')

summary({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Shell Search Provider]
DesktopId=@[email protected]
BusName=@[email protected]
ObjectPath=@path@/SearchProvider
Version=2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[D-BUS Service]
Name=@[email protected]
Exec=@libexecdir@/@appid@-search-provider
11 changes: 11 additions & 0 deletions search-provider/main.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This file is part of Highscore. License: GPL-3.0-or-later

int main (string[] args) {
Intl.bindtextdomain (Build.GETTEXT_PACKAGE, Build.GNOMELOCALEDIR);
Intl.bind_textdomain_codeset (Build.GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain (Build.GETTEXT_PACKAGE);

var app = new Planify.SearchProvider ();

return app.run (args);
}
47 changes: 47 additions & 0 deletions search-provider/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
search_provider_c_args = [
'-DGETTEXT_PACKAGE="' + meson.project_name () + '"',
'-DG_LOG_DOMAIN="PlanifySearchProvider"',
]

search_provider_sources = [
'main.vala',
'search-provider.vala'
]

search_provider_deps = [
gio_dep,
gtk_dep,
sqlite3_dep,
]

executable (
'io.github.alainmh23.planify-search-provider',
search_provider_sources,
config_file,
dependencies: search_provider_deps,
c_args: search_provider_c_args,
install: true,
install_dir: libexecdir
)

search_provider_conf = configuration_data()
search_provider_conf.set('appid', application_id)
search_provider_conf.set('path', application_path)
configure_file(
configuration: search_provider_conf,
input: 'io.github.alainm23.planify.SearchProvider.ini.in',
install_dir: datadir / 'gnome-shell' / 'search-providers',
install: true,
output: '@[email protected]'.format(application_id)
)

search_provider_dbus_conf = configuration_data()
search_provider_dbus_conf.set('appid', application_id)
search_provider_dbus_conf.set('libexecdir', libexecdir)
configure_file (
input: 'io.github.alainm23.planify.SearchProvider.service.in',
output: '@[email protected]'.format(application_id),
configuration: search_provider_dbus_conf,
install: true,
install_dir: datadir / 'dbus-1' / 'services'
)
28 changes: 28 additions & 0 deletions search-provider/search-provider.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// This file is part of Highscore. License: GPL-3.0+.

[DBus (name = "org.gnome.Shell.SearchProvider2")]
public class Planify.SearchProvider : Gtk.Application {
internal SearchProvider () {
Object (
application_id: Build.APPLICATION_ID + ".SearchProvider",
flags: ApplicationFlags.IS_SERVICE,
inactivity_timeout: 10000
);
}

construct {

}

protected override bool dbus_register (DBusConnection connection, string object_path) {
try {
connection.register_object (object_path, this);
} catch (IOError e) {
warning ("Could not register search provider: %s", e.message);
quit ();
}

return true;
}

}
11 changes: 8 additions & 3 deletions src/App.vala
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,15 @@ public class Planify : Adw.Application {
{ null }
};

construct {
application_id = Build.APPLICATION_ID;
flags |= ApplicationFlags.HANDLES_OPEN;
public Planify () {
Object (
application_id: Build.APPLICATION_ID,
flags: ApplicationFlags.HANDLES_OPEN
);
}


construct {
Intl.setlocale (LocaleCategory.ALL, "");
string langpack_dir = Path.build_filename (Build.INSTALL_PREFIX, "share", "locale");
Intl.bindtextdomain (Build.GETTEXT_PACKAGE, langpack_dir);
Expand Down
Loading

0 comments on commit c5b05c9

Please sign in to comment.