Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change references to unowned #382

Merged
merged 3 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow {
construct {
add_action_entries (ACTION_ENTRIES, this);

var application_instance = (Gtk.Application) GLib.Application.get_default ();
unowned var application_instance = (Gtk.Application) GLib.Application.get_default ();
foreach (var action in action_accelerators.get_keys ()) {
application_instance.set_accels_for_action (
ACTION_PREFIX + action, action_accelerators[action].to_array ()
Expand Down Expand Up @@ -233,7 +233,7 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow {
var task_lists = registry.list_sources (E.SOURCE_EXTENSION_TASK_LIST);

task_lists.foreach ((source) => {
E.SourceTaskList list = (E.SourceTaskList)source.get_extension (E.SOURCE_EXTENSION_TASK_LIST);
unowned var list = (E.SourceTaskList)source.get_extension (E.SOURCE_EXTENSION_TASK_LIST);

if (list.selected == true && source.enabled == true && !source.has_extension (E.SOURCE_EXTENSION_COLLECTION)) {
add_source (source);
Expand All @@ -256,7 +256,7 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow {

try {
var new_source = new E.Source (null, null);
var new_source_tasklist_extension = (E.SourceTaskList) new_source.get_extension (E.SOURCE_EXTENSION_TASK_LIST);
unowned var new_source_tasklist_extension = (E.SourceTaskList) new_source.get_extension (E.SOURCE_EXTENSION_TASK_LIST);
new_source.display_name = _("New list");
new_source_tasklist_extension.color = "#0e9a83";

Expand Down Expand Up @@ -296,7 +296,7 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow {
}

private void action_delete_selected_list () {
var list_row = ((Tasks.Widgets.SourceRow) listbox.get_selected_row ());
unowned var list_row = ((Tasks.Widgets.SourceRow) listbox.get_selected_row ());
var source = list_row.source;

if (Tasks.Application.model.is_remove_task_list_supported (source)) {
Expand All @@ -310,7 +310,7 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow {
transient_for = this
};

unowned Gtk.Widget trash_button = message_dialog.add_button (_("Delete Anyway"), Gtk.ResponseType.YES);
unowned var trash_button = message_dialog.add_button (_("Delete Anyway"), Gtk.ResponseType.YES);
trash_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);

message_dialog.response.connect ((response) => {
Expand Down Expand Up @@ -421,7 +421,7 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow {
}

private void update_source (E.Source source) {
E.SourceTaskList list = (E.SourceTaskList)source.get_extension (E.SOURCE_EXTENSION_TASK_LIST);
unowned var list = (E.SourceTaskList)source.get_extension (E.SOURCE_EXTENSION_TASK_LIST);

if (list.selected != true || source.enabled != true) {
remove_source (source);
Expand All @@ -432,7 +432,7 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow {
} else {
source_rows[source].update_request ();

var task_list_grid = (Tasks.Widgets.TaskListGrid) task_list_grid_stack.get_visible_child ();
unowned var task_list_grid = (Tasks.Widgets.TaskListGrid) task_list_grid_stack.get_visible_child ();
if (task_list_grid != null) {
task_list_grid.update_request ();
}
Expand Down
18 changes: 9 additions & 9 deletions src/TaskModel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public class Tasks.TaskModel : Object {

public async void add_task_list (E.Source task_list, E.Source collection_or_sibling) throws Error {
var registry = get_registry_sync ();
var task_list_extension = (E.SourceTaskList) task_list.get_extension (E.SOURCE_EXTENSION_TASK_LIST);
unowned var task_list_extension = (E.SourceTaskList) task_list.get_extension (E.SOURCE_EXTENSION_TASK_LIST);
var backend_name = get_collection_backend_name (collection_or_sibling, registry);

switch (backend_name.down ()) {
Expand Down Expand Up @@ -592,7 +592,7 @@ public class Tasks.TaskModel : Object {
debug ("WebDAV Rename '%s'", task_list.get_uid ());

var collection_source_webdav_session = new E.WebDAVSession (collection_source);
var source_webdav_extension = (E.SourceWebdav) task_list.get_extension (E.SOURCE_EXTENSION_WEBDAV_BACKEND);
unowned var source_webdav_extension = (E.SourceWebdav) task_list.get_extension (E.SOURCE_EXTENSION_WEBDAV_BACKEND);

var credentials_provider = new E.SourceCredentialsProvider (registry);
E.NamedParameters credentials;
Expand Down Expand Up @@ -676,7 +676,7 @@ public class Tasks.TaskModel : Object {
if (!task_list.has_extension (E.SOURCE_EXTENSION_TASK_LIST)) {
throw new Tasks.TaskModelError.INVALID_ARGUMENT ("Changing the color is not supported by this source.");
}
var task_list_extension = (E.SourceTaskList) task_list.get_extension (E.SOURCE_EXTENSION_TASK_LIST);
unowned var task_list_extension = (E.SourceTaskList) task_list.get_extension (E.SOURCE_EXTENSION_TASK_LIST);
var previous_color = task_list_extension.dup_color ();

var registry = get_registry_sync ();
Expand All @@ -700,7 +700,7 @@ public class Tasks.TaskModel : Object {
debug ("Update %s color for '%s'", backend_name, task_list.get_uid ());

var collection_source_webdav_session = new E.WebDAVSession (collection_source);
var source_webdav_extension = (E.SourceWebdav) task_list.get_extension (E.SOURCE_EXTENSION_WEBDAV_BACKEND);
unowned var source_webdav_extension = (E.SourceWebdav) task_list.get_extension (E.SOURCE_EXTENSION_WEBDAV_BACKEND);

var credentials_provider = new E.SourceCredentialsProvider (registry);
E.NamedParameters credentials;
Expand Down Expand Up @@ -750,7 +750,7 @@ public class Tasks.TaskModel : Object {

public async void add_task (E.Source list, ECal.Component task) throws Error {
ECal.Client client = get_client (list);
unowned ICal.Component comp = task.get_icalcomponent ();
unowned var comp = task.get_icalcomponent ();

debug (@"Adding task '$(comp.get_uid())'");

Expand All @@ -764,7 +764,7 @@ public class Tasks.TaskModel : Object {
public async void complete_task (E.Source list, ECal.Component task) throws Error {
ECal.Client client = get_client (list);

unowned ICal.Component comp = task.get_icalcomponent ();
unowned var comp = task.get_icalcomponent ();
var was_completed = comp.get_status () == ICal.PropertyStatus.COMPLETED;

if (was_completed) {
Expand Down Expand Up @@ -831,15 +831,15 @@ public class Tasks.TaskModel : Object {

public async void update_task (E.Source list, ECal.Component task, ECal.ObjModType mod_type) throws Error {
ECal.Client client = get_client (list);
unowned ICal.Component comp = task.get_icalcomponent ();
unowned var comp = task.get_icalcomponent ();

debug (@"Updating task '$(comp.get_uid())' [mod_type=$(mod_type)]");
yield client.modify_object (comp, mod_type, ECal.OperationFlags.NONE, null);
}

public async void remove_task (E.Source list, ECal.Component task, ECal.ObjModType mod_type) throws Error {
ECal.Client client = get_client (list);
unowned ICal.Component comp = task.get_icalcomponent ();
unowned var comp = task.get_icalcomponent ();

string uid = comp.get_uid ();
string? rid = task.has_recurrences () ? null : task.get_recurid_as_string ();
Expand Down Expand Up @@ -881,7 +881,7 @@ public class Tasks.TaskModel : Object {
}

private void debug_task (E.Source task_list, ECal.Component task) {
unowned ICal.Component comp = task.get_icalcomponent ();
unowned var comp = task.get_icalcomponent ();
var task_summary = comp.get_summary ();
var task_uid = comp.get_uid ();
var task_list_display_name = task_list.dup_display_name ();
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/TaskListGrid.vala
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid {
}

private void on_tasks_modified (Gee.Collection<ECal.Component> tasks) {
Tasks.Widgets.TaskRow task_row = null;
unowned Tasks.Widgets.TaskRow task_row = null;
var row_index = 0;

do {
Expand Down