-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
89 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<interface> | ||
<requires lib="gtk" version="4.0" /> | ||
<requires lib="Adw" version="1.0" /> | ||
<template class="TaskDetails" parent="AdwPreferencesWindow"> | ||
<property name="modal">true</property> | ||
<property name="title">Details</property> | ||
<child> | ||
<object class="AdwPreferencesPage"> | ||
<child> | ||
<object class="AdwPreferencesGroup"> | ||
<child> | ||
<object class="AdwActionRow"> | ||
<property name="title">Open in Calendar</property> | ||
<property name="activatable-widget">open_calendar_btn</property> | ||
<child type="suffix"> | ||
<object class="GtkButton" id="open_calendar_btn"> | ||
<property name="valign">center</property> | ||
<property name="icon-name">x-office-calendar-symbolic</property> | ||
<signal name="clicked" handler="on_calendar_open" /> | ||
<style> | ||
<class name="flat" /> | ||
</style> | ||
</object> | ||
</child> | ||
</object> | ||
</child> | ||
</object> | ||
</child> | ||
</object> | ||
</child> | ||
</template> | ||
</interface> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright 2023 Vlad Krupinskii <mrvladus@yandex.ru> | ||
# SPDX-License-Identifier: MIT | ||
|
||
import os | ||
from gi.repository import Adw, Gtk, GLib, Gio | ||
from .utils import Log | ||
|
||
|
||
@Gtk.Template(resource_path="/io/github/mrvladus/Errands/task_details.ui") | ||
class TaskDetails(Adw.PreferencesWindow): | ||
__gtype_name__ = "TaskDetails" | ||
|
||
def __init__(self, task) -> None: | ||
super().__init__() | ||
self.task = task | ||
self.set_transient_for(task.window) | ||
self.present() | ||
|
||
def _delete_old_ics(self): | ||
pass | ||
|
||
def _convert_to_ics(self): | ||
ics_text: str = "hello" | ||
cache_dir: str = os.path.join(GLib.get_user_cache_dir(), "list") | ||
if not os.path.exists(cache_dir): | ||
os.mkdir(cache_dir) | ||
with open(os.path.join(cache_dir, f"{self.task.task['id']}.ics"), "w") as f: | ||
f.write(ics_text) | ||
|
||
@Gtk.Template.Callback() | ||
def on_calendar_open(self, _btn): | ||
self._convert_to_ics() | ||
file: Gio.File = Gio.File.new_for_path( | ||
os.path.join( | ||
GLib.get_user_cache_dir(), "list", f"{self.task.task['id']}.ics" | ||
) | ||
) | ||
Gtk.FileLauncher.new(file).launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters