From 270a7ce391ef867a603e3016ac9973e335d6e190 Mon Sep 17 00:00:00 2001 From: Diego Garcia Gangl Date: Mon, 2 May 2022 18:49:20 -0300 Subject: [PATCH 001/288] Comment out taglist and tasklist in main window We will replace these with listviews once we are on Gtk4. --- GTG/core/plugins/api.py | 14 +-- GTG/gtk/browser/main_window.py | 161 +++++++++++++++++---------------- 2 files changed, 88 insertions(+), 87 deletions(-) diff --git a/GTG/core/plugins/api.py b/GTG/core/plugins/api.py index 3af6dac8da..81e2be29c6 100644 --- a/GTG/core/plugins/api.py +++ b/GTG/core/plugins/api.py @@ -59,8 +59,8 @@ def __init__(self, self.__ui = self.__view_manager.browser self.__builder = self.__ui.get_builder() self.__task_id = None - self.__view_manager.browser.selection.connect( - "changed", self.__selection_changed) + # self.__view_manager.browser.selection.connect( + # "changed", self.__selection_changed) self.taskwidget_id = 0 self.taskwidget_widg = [] @@ -223,12 +223,12 @@ def set_bgcolor_func(self, func=None): browser = self.get_browser() # set default bgcolor? - if func is None: - func = browser.tv_factory.get_task_bg_color + # if func is None: + # func = browser.tv_factory.get_task_bg_color - for pane in browser.vtree_panes.values(): - pane.set_bg_color(func, 'bg_color') - pane.basetree.get_basetree().refresh_all() + # for pane in browser.vtree_panes.values(): + # pane.set_bg_color(func, 'bg_color') + # pane.basetree.get_basetree().refresh_all() # file saving/loading ======================================================= def load_configuration_object(self, plugin_name, filename, diff --git a/GTG/gtk/browser/main_window.py b/GTG/gtk/browser/main_window.py index 470cb2c496..4ecfc91a88 100644 --- a/GTG/gtk/browser/main_window.py +++ b/GTG/gtk/browser/main_window.py @@ -39,7 +39,7 @@ from GTG.gtk.browser.modify_tags import ModifyTagsDialog from GTG.gtk.browser.delete_tag import DeleteTagsDialog from GTG.gtk.browser.tag_context_menu import TagContextMenu -from GTG.gtk.browser.treeview_factory import TreeviewFactory +# from GTG.gtk.browser.treeview_factory import TreeviewFactory from GTG.gtk.editor.calendar import GTGCalendar from GTG.gtk.tag_completion import TagCompletion from GTG.core.dates import Date @@ -80,25 +80,25 @@ def __init__(self, requester, app): self.search_timeout = None # Treeviews handlers - self.vtree_panes = {} - self.tv_factory = TreeviewFactory(self.req, self.config) + # self.vtree_panes = {} + # self.tv_factory = TreeviewFactory(self.req, self.config) # Active Tasks - self.activetree = self.req.get_tasks_tree(name='active', refresh=False) - self.vtree_panes['active'] = \ - self.tv_factory.active_tasks_treeview(self.activetree) + # self.activetree = self.req.get_tasks_tree(name='active', refresh=False) + # self.vtree_panes['active'] = \ + # self.tv_factory.active_tasks_treeview(self.activetree) # Workview Tasks - self.workview_tree = \ - self.req.get_tasks_tree(name='workview', refresh=False) - self.vtree_panes['workview'] = \ - self.tv_factory.active_tasks_treeview(self.workview_tree) + # self.workview_tree = \ + # self.req.get_tasks_tree(name='workview', refresh=False) + # self.vtree_panes['workview'] = \ + # self.tv_factory.active_tasks_treeview(self.workview_tree) # Closed Tasks - self.closedtree = \ - self.req.get_tasks_tree(name='closed', refresh=False) - self.vtree_panes['closed'] = \ - self.tv_factory.closed_tasks_treeview(self.closedtree) + # self.closedtree = \ + # self.req.get_tasks_tree(name='closed', refresh=False) + # self.vtree_panes['closed'] = \ + # self.tv_factory.closed_tasks_treeview(self.closedtree) # YOU CAN DEFINE YOUR INTERNAL MECHANICS VARIABLES BELOW # Setup GTG icon theme @@ -269,9 +269,9 @@ def _init_ui_widget(self): actionable tasks (workview), closed tasks and creates ModifyTagsDialog & Calendar """ # Tasks treeviews - self.open_pane.add(self.vtree_panes['active']) - self.actionable_pane.add(self.vtree_panes['workview']) - self.closed_pane.add(self.vtree_panes['closed']) + # self.open_pane.add(self.vtree_panes['active']) + # self.actionable_pane.add(self.vtree_panes['workview']) + # self.closed_pane.add(self.vtree_panes['closed']) tag_completion = TagCompletion(self.req.get_tag_tree()) self.modifytags_dialog = ModifyTagsDialog(tag_completion, self.req, self.app) @@ -407,51 +407,51 @@ def _init_signal_connections(self): # Store window position self.connect('size-allocate', self.on_size_allocate) - # Active tasks TreeView - self.vtree_panes['active'].connect('row-activated', self.on_edit_active_task) - self.vtree_panes['active'].connect('cursor-changed', self.on_cursor_changed) - - tsk_treeview_btn_press = self.on_task_treeview_click_begin - self.active_pane_gesture_single = Gtk.GestureSingle(widget=self.vtree_panes['active'], button=Gdk.BUTTON_SECONDARY, - propagation_phase=Gtk.PropagationPhase.CAPTURE) - self.active_pane_gesture_single.connect('begin', tsk_treeview_btn_press) - task_treeview_key_press = self.on_task_treeview_key_press_event - self.active_pane_key_controller = Gtk.EventControllerKey(widget=self.vtree_panes['active']) - self.active_pane_key_controller.connect('key-pressed', task_treeview_key_press) - self.vtree_panes['active'].connect('node-expanded', self.on_task_expanded) - self.vtree_panes['active'].connect('node-collapsed', self.on_task_collapsed) - - # Workview tasks TreeView - self.vtree_panes['workview'].connect('row-activated', self.on_edit_active_task) - self.vtree_panes['workview'].connect('cursor-changed', self.on_cursor_changed) - - tsk_treeview_btn_press = self.on_task_treeview_click_begin - self.workview_pane_gesture_single = Gtk.GestureSingle(widget=self.vtree_panes['workview'], button=Gdk.BUTTON_SECONDARY, - propagation_phase=Gtk.PropagationPhase.CAPTURE) - self.workview_pane_gesture_single.connect('begin', tsk_treeview_btn_press) - task_treeview_key_press = self.on_task_treeview_key_press_event - self.workview_pane_key_controller = Gtk.EventControllerKey(widget=self.vtree_panes['workview']) - self.workview_pane_key_controller.connect('key-pressed', task_treeview_key_press) - self.vtree_panes['workview'].set_col_visible('startdate', False) - - # Closed tasks Treeview - self.vtree_panes['closed'].connect('row-activated', self.on_edit_done_task) - # I did not want to break the variable and there was no other - # option except this name:(Nimit) - clsd_tsk_btn_prs = self.on_closed_task_treeview_click_begin - self.closed_pane_gesture_single = Gtk.GestureSingle(widget=self.vtree_panes['closed'], button=Gdk.BUTTON_SECONDARY, - propagation_phase=Gtk.PropagationPhase.CAPTURE) - self.closed_pane_gesture_single.connect('begin', clsd_tsk_btn_prs) - clsd_tsk_key_prs = self.on_closed_task_treeview_key_press_event - self.closed_pane_key_controller = Gtk.EventControllerKey(widget=self.vtree_panes['closed']) - self.closed_pane_key_controller.connect('key-pressed', clsd_tsk_key_prs) - self.vtree_panes['closed'].connect('cursor-changed', self.on_cursor_changed) + # # Active tasks TreeView + # self.vtree_panes['active'].connect('row-activated', self.on_edit_active_task) + # self.vtree_panes['active'].connect('cursor-changed', self.on_cursor_changed) + + # tsk_treeview_btn_press = self.on_task_treeview_click_begin + # self.active_pane_gesture_single = Gtk.GestureSingle(widget=self.vtree_panes['active'], button=Gdk.BUTTON_SECONDARY, + # propagation_phase=Gtk.PropagationPhase.CAPTURE) + # self.active_pane_gesture_single.connect('begin', tsk_treeview_btn_press) + # task_treeview_key_press = self.on_task_treeview_key_press_event + # self.active_pane_key_controller = Gtk.EventControllerKey(widget=self.vtree_panes['active']) + # self.active_pane_key_controller.connect('key-pressed', task_treeview_key_press) + # self.vtree_panes['active'].connect('node-expanded', self.on_task_expanded) + # self.vtree_panes['active'].connect('node-collapsed', self.on_task_collapsed) + + # # Workview tasks TreeView + # self.vtree_panes['workview'].connect('row-activated', self.on_edit_active_task) + # self.vtree_panes['workview'].connect('cursor-changed', self.on_cursor_changed) + + # tsk_treeview_btn_press = self.on_task_treeview_click_begin + # self.workview_pane_gesture_single = Gtk.GestureSingle(widget=self.vtree_panes['workview'], button=Gdk.BUTTON_SECONDARY, + # propagation_phase=Gtk.PropagationPhase.CAPTURE) + # self.workview_pane_gesture_single.connect('begin', tsk_treeview_btn_press) + # task_treeview_key_press = self.on_task_treeview_key_press_event + # self.workview_pane_key_controller = Gtk.EventControllerKey(widget=self.vtree_panes['workview']) + # self.workview_pane_key_controller.connect('key-pressed', task_treeview_key_press) + # self.vtree_panes['workview'].set_col_visible('startdate', False) + + # # Closed tasks Treeview + # self.vtree_panes['closed'].connect('row-activated', self.on_edit_done_task) + # # I did not want to break the variable and there was no other + # # option except this name:(Nimit) + # clsd_tsk_btn_prs = self.on_closed_task_treeview_click_begin + # self.closed_pane_gesture_single = Gtk.GestureSingle(widget=self.vtree_panes['closed'], button=Gdk.BUTTON_SECONDARY, + # propagation_phase=Gtk.PropagationPhase.CAPTURE) + # self.closed_pane_gesture_single.connect('begin', clsd_tsk_btn_prs) + # clsd_tsk_key_prs = self.on_closed_task_treeview_key_press_event + # self.closed_pane_key_controller = Gtk.EventControllerKey(widget=self.vtree_panes['closed']) + # self.closed_pane_key_controller.connect('key-pressed', clsd_tsk_key_prs) + # self.vtree_panes['closed'].connect('cursor-changed', self.on_cursor_changed) b_signals = BackendSignals() b_signals.connect(b_signals.BACKEND_FAILED, self.on_backend_failed) b_signals.connect(b_signals.BACKEND_STATE_TOGGLED, self.remove_backend_infobar) b_signals.connect(b_signals.INTERACTION_REQUESTED, self.on_backend_needing_interaction) - self.selection = self.vtree_panes['active'].get_selection() + # self.selection = self.vtree_panes['active'].get_selection() # HELPER FUNCTIONS ########################################################## @@ -588,20 +588,20 @@ def restore_state_from_conf(self): self.on_sidebar_width) # Callbacks for sorting and restoring previous state - model = self.vtree_panes['active'].get_model() - model.connect('sort-column-changed', self.on_sort_column_changed) - sort_column = self.config.get('tasklist_sort_column') - sort_order = self.config.get('tasklist_sort_order') + # model = self.vtree_panes['active'].get_model() + # model.connect('sort-column-changed', self.on_sort_column_changed) + # sort_column = self.config.get('tasklist_sort_column') + # sort_order = self.config.get('tasklist_sort_order') - if sort_column and sort_order: - sort_column, sort_order = int(sort_column), int(sort_order) - model.set_sort_column_id(sort_column, sort_order) + # if sort_column and sort_order: + # sort_column, sort_order = int(sort_column), int(sort_order) + # model.set_sort_column_id(sort_column, sort_order) - self.restore_collapsed_tasks() + # self.restore_collapsed_tasks() - view_name = PANE_STACK_NAMES_MAP_INVERTED.get(self.config.get('view'), - PANE_STACK_NAMES_MAP_INVERTED['active']) - self.stack_switcher.get_stack().set_visible_child_name(view_name) + # view_name = PANE_STACK_NAMES_MAP_INVERTED.get(self.config.get('view'), + # PANE_STACK_NAMES_MAP_INVERTED['active']) + # self.stack_switcher.get_stack().set_visible_child_name(view_name) def open_task(req, t): """ Open the task if loaded. Otherwise ask for next iteration """ @@ -677,12 +677,13 @@ def on_about_close(self, widget, response): def on_cursor_changed(self, widget=None): """Callback when the treeview's cursor changes.""" - if self.has_any_selection(): - self.defer_btn.set_sensitive(True) - self.defer_menu_btn.set_sensitive(True) - else: - self.defer_btn.set_sensitive(False) - self.defer_menu_btn.set_sensitive(False) + ... + # if self.has_any_selection(): + # self.defer_btn.set_sensitive(True) + # self.defer_menu_btn.set_sensitive(True) + # else: + # self.defer_btn.set_sensitive(False) + # self.defer_menu_btn.set_sensitive(False) def on_tagcontext_deactivate(self, menushell): self.reset_cursor() @@ -705,8 +706,8 @@ def _on_sidebar_visible(self, obj, param): assert param.name == 'visible' visible = obj.get_property(param.name) self.config.set("tag_pane", visible) - if visible and not self.tagtreeview: - self.init_tags_sidebar() + # if visible and not self.tagtreeview: + # self.init_tags_sidebar() def on_collapse_all_tasks(self, action, param): """Collapse all tasks.""" @@ -834,10 +835,10 @@ def selecter(treemodelsort, path, iter, self): data = quick_add.parse(text) # event that is set when the new task is created self.__last_quick_added_tid_event = threading.Event() - self.__quick_add_select_handle = \ - self.vtree_panes['active'].get_model().connect( - "row-inserted", select_next_added_task_in_browser, - self) + # self.__quick_add_select_handle = \ + # self.vtree_panes['active'].get_model().connect( + # "row-inserted", select_next_added_task_in_browser, + # self) task = self.req.new_task(newtask=True) self.__last_quick_added_tid = task.get_id() self.__last_quick_added_tid_event.set() From 0a71f24a36e9cea363bb12079c3db5332b9433f6 Mon Sep 17 00:00:00 2001 From: Raidro Manchester Date: Fri, 22 Oct 2021 19:33:36 +0300 Subject: [PATCH 002/288] gtk4: update imports initial commit that makes it try to run with 4.0 --- GTG/gtg.in | 6 +++--- pylint.rc | 2 +- run-tests | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/GTG/gtg.in b/GTG/gtg.in index 78ef9739fd..e7d64b2a4d 100755 --- a/GTG/gtg.in +++ b/GTG/gtg.in @@ -71,9 +71,9 @@ if __name__ == "__main__": pass import gi -gi.require_version('Gdk', '3.0') -gi.require_version('Gtk', '3.0') -gi.require_version('GtkSource', '4') +gi.require_version('Gdk', '4.0') +gi.require_version('Gtk', '4.0') +gi.require_version('GtkSource', '5') from gi.repository import GLib diff --git a/pylint.rc b/pylint.rc index 8aa7818fe8..b05b82d367 100644 --- a/pylint.rc +++ b/pylint.rc @@ -1,7 +1,7 @@ [MASTER] # Python code to execute -init-hook='import gi; gi.require_version("Gtk", "3.0");' +init-hook='import gi; gi.require_version("Gtk", "4.0");' # Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the # number of processors available to use. diff --git a/run-tests b/run-tests index 1dc45ecc83..c95b7f7a32 100755 --- a/run-tests +++ b/run-tests @@ -28,9 +28,9 @@ import sys import pytest import gi -gi.require_version('Gdk', '3.0') -gi.require_version('Gtk', '3.0') -gi.require_version('GtkSource', '4') +gi.require_version('Gdk', '4.0') +gi.require_version('Gtk', '4.0') +gi.require_version('GtkSource', '5') if __name__ == "__main__": From bae419dc2906d997ab0acd54668cdfc7b853e98b Mon Sep 17 00:00:00 2001 From: Raidro Manchester Date: Fri, 22 Oct 2021 19:41:43 +0300 Subject: [PATCH 003/288] gtk4: stop using GdkScreen The remaining relevant functionality has been replaced with GdkDisplay. Gdk.Screen.get_width in pixels has no replacement, but the function that uses it is literally never called, so I removed it --- GTG/gtk/application.py | 6 +++--- GTG/gtk/editor/calendar.py | 15 --------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/GTG/gtk/application.py b/GTG/gtk/application.py index 13c42e936e..6f5816976e 100644 --- a/GTG/gtk/application.py +++ b/GTG/gtk/application.py @@ -271,13 +271,13 @@ def init_plugin_engine(self): def init_style(self): """Load the application's CSS file.""" - screen = Gdk.Screen.get_default() + display = Gdk.Display.get_default() provider = Gtk.CssProvider() - add_provider = Gtk.StyleContext.add_provider_for_screen + add_provider = Gtk.StyleContext.add_provider_for_display css_path = os.path.join(CSS_DIR, 'style.css') provider.load_from_path(css_path) - add_provider(screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + add_provider(display, provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) def toggle_darkmode(self, state=True): """Use dark mode theme.""" diff --git a/GTG/gtk/editor/calendar.py b/GTG/gtk/editor/calendar.py index 5496af1155..b0ac63f25e 100644 --- a/GTG/gtk/editor/calendar.py +++ b/GTG/gtk/editor/calendar.py @@ -105,21 +105,6 @@ def __mark_today_in_bold(self): # to let GTK solve it's bussiness. self.__calendar.clear_marks() - def move_calendar_inside(self, width, height, x, y): - """ This method moves the calender inside the screen whenever part of - it is displayed outside the screen """ - screen_width = Gdk.Screen.width() - # To display calendar inside the screen when editor window is - # outside leftside of the screen - if x < width: - self.__window.move(2, y - height) - # To display calendar inside the screen when editor window is outside - # rightside of the screen - elif x > (screen_width - 2): - self.__window.move(screen_width - width - 2, y - height) - else: - self.__window.move(x - width, y - height) - def show(self): self.__window.show() From 428501ba08d4c6da28e173ecf9d73b259c5f9ad2 Mon Sep 17 00:00:00 2001 From: Raidro Manchester Date: Fri, 22 Oct 2021 19:52:20 +0300 Subject: [PATCH 004/288] gtk4: port to GdkClipboard very simple change here really, just set instead of set_text, and GtkWidget.get_clipboard --- GTG/gtk/editor/taskview.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/GTG/gtk/editor/taskview.py b/GTG/gtk/editor/taskview.py index 5becb10cc8..8b60b6ad83 100644 --- a/GTG/gtk/editor/taskview.py +++ b/GTG/gtk/editor/taskview.py @@ -653,9 +653,8 @@ def do_populate_popup(self, popup) -> None: def copy_url(self, menu_item, url: str) -> None: """Copy url to clipboard.""" - clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) - clipboard.set_text(url, -1) - clipboard.store() + clipboard = self.get_clipboard() + clipboard.set(url) # -------------------------------------------------------------------------- # PUBLIC API From 1d4b0ced9e269217ddca39e43ea5874ef6ca4929 Mon Sep 17 00:00:00 2001 From: Raidro Manchester Date: Fri, 22 Oct 2021 19:53:53 +0300 Subject: [PATCH 005/288] gtk4: stop using get_current_event Its now not global, but from the event controller --- GTG/gtk/browser/main_window.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/GTG/gtk/browser/main_window.py b/GTG/gtk/browser/main_window.py index 4ecfc91a88..ec81d0caf2 100644 --- a/GTG/gtk/browser/main_window.py +++ b/GTG/gtk/browser/main_window.py @@ -885,7 +885,7 @@ def on_tag_treeview_click_begin(self, gesture, sequence): """ deals with mouse click event on the tag tree """ - event = Gtk.get_current_event() + event = gesture.get_current_event() log.debug("Received button event #%d at %d, %d", event.button, event.x, event.y) if event.button.button == 3: @@ -930,7 +930,7 @@ def on_tag_treeview_click_begin(self, gesture, sequence): def on_tag_treeview_key_press_event(self, controller, keyval, keycode, state): keyname = Gdk.keyval_name(keyval) - event = Gtk.get_current_event() + event = controller.get_current_event() is_shift_f10 = (keyname == "F10" and state & Gdk.ModifierType.SHIFT_MASK) if is_shift_f10 or keyname == "Menu": selected_tags = self.get_selected_tags(nospecial=True) @@ -978,7 +978,7 @@ def on_delete_tag(self, event): def on_task_treeview_click_begin(self, gesture, sequence): """ Pop up context menu on right mouse click in the main task tree view """ - event = Gtk.get_current_event() + event = gesture.get_current_event() treeview = gesture.get_widget() log.debug("Received button event #%s at %d,%d", event.button, event.x, event.y) @@ -1002,7 +1002,7 @@ def on_task_treeview_click_begin(self, gesture, sequence): def on_task_treeview_key_press_event(self, controller, keyval, keycode, state): keyname = Gdk.keyval_name(keyval) - event = Gtk.get_current_event() + event = controller.get_current_event() is_shift_f10 = (keyname == "F10" and state & Gdk.ModifierType.SHIFT_MASK) if is_shift_f10 or keyname == "Menu": @@ -1010,7 +1010,7 @@ def on_task_treeview_key_press_event(self, controller, keyval, keycode, state): return True def on_closed_task_treeview_click_begin(self, gesture, sequence): - event = Gtk.get_current_event() + event = gesture.get_current_event() treeview = gesture.get_widget() if event.button.button == 3: x = int(event.x) @@ -1031,7 +1031,7 @@ def on_closed_task_treeview_click_begin(self, gesture, sequence): def on_closed_task_treeview_key_press_event(self, controller, keyval, keycode, state): keyname = Gdk.keyval_name(keyval) - event = Gtk.get_current_event() + event = controller.get_current_event() is_shift_f10 = (keyname == "F10" and state & Gdk.ModifierType.SHIFT_MASK) if is_shift_f10 or keyname == "Menu": From a78da23dd6fbfcb7e3b2057df3bfd6f98598a148 Mon Sep 17 00:00:00 2001 From: Raidro Manchester Date: Fri, 22 Oct 2021 21:34:04 +0300 Subject: [PATCH 006/288] gtk4: convert ui files Converts the UI files with gtk4-builder-tool per the migration instructions.. I fixed a few property renames and stuff like that along the way. I tried to minimize the diff by reverting the stupid changes the tool did that blew up the diff (replaces False with 0 everywhere, sometimes messes up indentation) --- GTG/gtk/data/calendar.ui | 24 +- GTG/gtk/data/context_menus.ui | 2 +- GTG/gtk/data/general_preferences.ui | 100 +---- GTG/gtk/data/help_overlay.ui | 57 +-- GTG/gtk/data/main_window.ui | 147 +++--- GTG/gtk/data/modify_tags.ui | 83 ++-- GTG/gtk/data/plugins.ui | 64 +-- GTG/gtk/data/preferences.ui | 13 +- GTG/gtk/data/tag_editor.ui | 99 ++-- GTG/gtk/data/task_editor.ui | 675 ++++++++++++---------------- 10 files changed, 457 insertions(+), 807 deletions(-) diff --git a/GTG/gtk/data/calendar.ui b/GTG/gtk/data/calendar.ui index 1993333906..a7cf018832 100644 --- a/GTG/gtk/data/calendar.ui +++ b/GTG/gtk/data/calendar.ui @@ -1,21 +1,17 @@ - - + False GDK_STRUCTURE_MASK | GDK_PROXIMITY_OUT_MASK False True True - True - True - + - True False 12 12 @@ -23,38 +19,28 @@ 12 vertical - - True - True - + - True False 8 True Now - True - True True Soon - True - True True Someday - True - True True @@ -66,13 +52,11 @@ Clear - True - True True 8 - + diff --git a/GTG/gtk/data/context_menus.ui b/GTG/gtk/data/context_menus.ui index d415627df0..5c711140f9 100644 --- a/GTG/gtk/data/context_menus.ui +++ b/GTG/gtk/data/context_menus.ui @@ -1,6 +1,6 @@ - +
diff --git a/GTG/gtk/data/general_preferences.ui b/GTG/gtk/data/general_preferences.ui index 9c1b519ac9..c46c4dcc5d 100644 --- a/GTG/gtk/data/general_preferences.ui +++ b/GTG/gtk/data/general_preferences.ui @@ -1,7 +1,6 @@ - - + 999 30 @@ -9,24 +8,19 @@ 10 - True False never 450 - + - True False - none - + - True start False vertical - True False start 12 @@ -36,13 +30,10 @@ none - True - True False - + - True False 12 12 @@ -50,13 +41,11 @@ 8 - True False center vertical - True False Show description preview 0 @@ -64,7 +53,6 @@ - True False Show a task excerpt next to each task in the Task Browser 0 @@ -77,26 +65,21 @@ - True end center True - True - + - True - True False - + - True False 12 12 @@ -104,13 +87,11 @@ 8 - True False center vertical - True False Enable colored backgrounds 0 @@ -118,7 +99,6 @@ - True False Show colored backgrounds for a task based on the colors of its tags 0 @@ -131,27 +111,22 @@ - True True - True end center - + - True - True False False - + - True False 12 12 @@ -159,13 +134,11 @@ 8 - True False center vertical - True False Start of the day 0 @@ -173,7 +146,6 @@ - True False Automatically refreshes the task list and adjusts the "Actionable" view 0 @@ -186,8 +158,6 @@ - True - True True center end @@ -200,18 +170,15 @@ - + - True - True False - + - True False 12 12 @@ -219,7 +186,6 @@ 8 - True False Task Editor font 0 @@ -227,10 +193,8 @@ - True True end - True True Sans 12 @@ -238,17 +202,14 @@ - + 100 - True - True - + - True False 12 12 @@ -256,7 +217,6 @@ 8 - True False Dark Mode 0 @@ -265,16 +225,14 @@ autoclean_button - True True - True end center - + - - - - - True - False - Tags + + + + + + + + + + + + False + Tags + + @@ -163,31 +159,22 @@ - - False - - True False vertical - True - True True True center - + - True False 6 - True - True True True True @@ -200,67 +187,60 @@ Save Search - True False - False win.save_search - + - True True - True vertical - True False crossfade - - True - True - - - - - + open_view Open - + + + + + + + + - - True - True - - - - - + actionable_view Actionable - 1 - + + + + + + + + - - True - True - - - - - + closed_view Closed - 2 - + + + + + + + + @@ -268,13 +248,10 @@ - True False - True True - True True True True @@ -300,27 +277,21 @@ - True False - True - True False stack - True False - False Create a new task center app.new_task - True False list-add-symbolic 1 @@ -328,53 +299,41 @@ - + - True False True main_menu - True False open-menu-symbolic - - end - - + - True False - False Activate Search Entry center win.search - True False edit-find-symbolic 1 - - end - - True False start - True + Start Tomorrow False False True @@ -404,14 +363,12 @@ - True False False True defer_menu - True False False start diff --git a/GTG/gtk/data/modify_tags.ui b/GTG/gtk/data/modify_tags.ui index 6acaebc9b3..f2f303ccf4 100644 --- a/GTG/gtk/data/modify_tags.ui +++ b/GTG/gtk/data/modify_tags.ui @@ -1,66 +1,23 @@ - + False 12 Modify Tags - center-on-parent - dialog - + - True False vertical - 6 - - - True - False - end - - - Cancel - False - True - True - False - - - False - False - 0 - - - - - Apply - False - True - True - True - True - False - - - - - - - + 2 - True False Enter the name of the tag(s) you wish to add or remove: - True - True True True @@ -69,7 +26,6 @@ - True False Hint: you can add several tags by separating them with space. Place '!' before tags you want to remove. @@ -81,18 +37,39 @@ space. Place '!' before tags you want to remove. Apply to subtasks - True - True - False - False - True - modifytags_cancel modifytags_ok + modifytags_cancel + + + False + end + + + Apply + True + 1 + + + + + False + False + 0 + + + + + Cancel + False + + + + diff --git a/GTG/gtk/data/plugins.ui b/GTG/gtk/data/plugins.ui index 6ef8628fc3..e6438f2d3a 100644 --- a/GTG/gtk/data/plugins.ui +++ b/GTG/gtk/data/plugins.ui @@ -1,12 +1,9 @@ - - + False 5 - mouse - dialog system-run-symbolic @@ -16,34 +13,27 @@ - True False vertical 2 - True False end - True False - 0 - none - + - True False 12 True - + - True False <b>Dependencies</b> True @@ -57,49 +47,30 @@ False 10 - center-on-parent - 750 + 500 500 - dialog - + - True False vertical - - - False - - - - - - - - - True False vertical 6 240 - True - True 12 12 - in - + True + - True True - True False False horizontal @@ -108,12 +79,11 @@ - + - True False 12 12 @@ -122,23 +92,20 @@ Help - True - True True app.open_help - True True end False + False _Configure Plugin False - True True True @@ -150,8 +117,6 @@ _About Plugin - True - True True True @@ -168,5 +133,16 @@ + + + False + + + + + + + + diff --git a/GTG/gtk/data/preferences.ui b/GTG/gtk/data/preferences.ui index ecbf568f6f..312feaca9b 100644 --- a/GTG/gtk/data/preferences.ui +++ b/GTG/gtk/data/preferences.ui @@ -1,37 +1,28 @@ - - + False 700 500 - dialog - True False Preferences - False - 0 - True - True False - True False False vertical 150 - True False True stack @@ -41,14 +32,12 @@ - True False vertical - True False crossfade diff --git a/GTG/gtk/data/tag_editor.ui b/GTG/gtk/data/tag_editor.ui index 3076361973..e8c852ef0e 100644 --- a/GTG/gtk/data/tag_editor.ui +++ b/GTG/gtk/data/tag_editor.ui @@ -1,22 +1,15 @@ - - + diff --git a/GTG/gtk/data/task_editor.ui b/GTG/gtk/data/task_editor.ui index 3a833e5999..23340790e7 100644 --- a/GTG/gtk/data/task_editor.ui +++ b/GTG/gtk/data/task_editor.ui @@ -1,7 +1,6 @@ - - +
@@ -22,9 +21,8 @@
False - + - True False 12 12 @@ -33,334 +31,319 @@ vertical - True False - False + 0 slide-left-right - True + 1 - - True - False - vertical - - - True - False - Every: - True - - - - - True - False - 6 - 6 - - - - - True + + page0 + Recurring + + False + vertical - - True + + False + Every: + True + + + + False - 5 - Repeat + 6 + 6 - + + False + + + False + 5 + Repeat + + + + + Tick to activate + 5 + True + + + + + + + + False + 6 + 6 + + + + True True end True - False - Tick to activate - 5 - True - True - + True + Daily + + + + + + True + True + True + Every other day + + + + + + True + True + True + Weekly + page1 + + + + + True + True + True + Monthly + page2 + + + + + True + True + True + Yearly + page3 - - - - True - False - 6 - 6 - - - - - True - True - True - Daily - - - - - - True - True - True - Every other day - - - - - - True - True - True - Weekly - page1 - - - - - True - True - True - Monthly - page2 - - - - - True - True - True - Yearly - page3 - - + - - page0 - Recurring - - - True - False - vertical - - - True - True - True - Weekly - page0 - True - True - - - - - Monday - True - True - True - On Monday - - - - - - Tuesday - True - True - True - On Tuesday - - - - - - Wednesday - True - True - True - On Wednesday - - - - - - Thursday - True - True - True - On Thursday - - - - - - Friday - True - True - True - On Friday - - - - - - Saturday - True - True - True - On Saturday - - - - - - Sunday - True - True - True - On Sunday - - - - - - True + + page1 + Weekly + + False - 6 - 6 - - - - - True - True - True - On This Day - + vertical + + + True + True + True + Weekly + page0 + True + True + + + + + Monday + True + True + True + On Monday + + + + + + Tuesday + True + True + True + On Tuesday + + + + + + Wednesday + True + True + True + On Wednesday + + + + + + Thursday + True + True + True + On Thursday + + + + + + Friday + True + True + True + On Friday + + + + + + Saturday + True + True + True + On Saturday + + + + + + Sunday + True + True + True + On Sunday + + + + + + False + 6 + 6 + + + + + True + True + True + On This Day + + + - + - - page1 - Weekly - - - True - False - vertical - - - True - True - True - Monthly - page0 - True - True - - - - - True - True - 0 - False - False - True - - - - - - True + + page2 + Monthly + + False - 6 - 6 - - - - - True - True - True - On This Day - + vertical + + + True + True + True + Monthly + page0 + True + True + + + + + 0 + 0 + 0 + True + + + + + + False + 6 + 6 + + + + + True + True + True + On This Day + + + - + - - page2 - Monthly - - - True - False - vertical - - - True - True - True - Yearly - page0 - True - True - - - - - True - True - - - - - - True + + page3 + Yearly + + False - 6 - 6 - - - - - True - True - True - On This Day - + vertical + + + True + True + True + Yearly + page0 + True + True + + + + + + + + + + False + 6 + 6 + + + + + True + True + True + On This Day + + + - + - - page3 - Yearly - - + - - @@ -371,18 +354,15 @@ 400 utility - + - True False vertical - True False - True False 10 10 @@ -392,27 +372,21 @@ Open Parent - True False - False - Open the parent task (creating a parent if it doesn't have one) + Open the parent task (creating a parent if it doesn't have one) app.editor.show_parent - True False - True False - False Insert a subtask in this task app.new_subtask - True False format-indent-more-symbolic 2 @@ -422,15 +396,12 @@ - True False - False Add tags to this task app.editor.open_tags_popup tags_popover - True False user-bookmarks-symbolic 2 @@ -440,15 +411,12 @@ - True - True True Set this task to repeat recurring_popover - True False True view-refresh-symbolic @@ -463,13 +431,11 @@ - True False 10 10 - True False Starts on 0 @@ -480,8 +446,6 @@ - True - True 10 @@ -492,13 +456,11 @@ - True False 10 10 - True False Due on 0 @@ -509,8 +471,6 @@ - True - True 10 @@ -521,13 +481,11 @@ - True False 10 10 - True False Closed on 0 @@ -538,8 +496,6 @@ - True - True 10 @@ -556,39 +512,32 @@ 400 300 - True - True - + - True - True word 5 5 - + - True False vertical - + - True False Task - True + False Mark as Done False - False Mark the task as done center app.mark_as_done @@ -599,34 +548,28 @@ + False Mark as Not Done False - False Mark the task as to be done center app.mark_as_done - + - True False - False Task action menu center editor_menu - True False view-more-symbolic 1 - - end - @@ -634,10 +577,9 @@ False closeddate_entry - False - + False + - True False 12 12 @@ -646,7 +588,6 @@ vertical - True False @@ -654,15 +595,14 @@ - + False duedate_entry - False - + False + - True False 12 12 @@ -671,7 +611,6 @@ vertical - True False 2020 2 @@ -679,15 +618,12 @@ - True False 8 True Now - True - True False True @@ -696,8 +632,6 @@ Soon - True - True False True @@ -706,8 +640,6 @@ Someday - True - True False True @@ -721,8 +653,6 @@ Clear - True - True False True 8 @@ -730,15 +660,14 @@ - + False startdate_entry - False - + False + - True False 12 12 @@ -747,7 +676,6 @@ vertical - True False 2020 2 @@ -756,8 +684,6 @@ Clear - True - True False True @@ -767,14 +693,13 @@ - + False tags - + - True False 12 12 @@ -783,8 +708,6 @@ vertical - True - True 10 edit-find-symbolic False @@ -794,14 +717,10 @@ - True - True - in + True 200 - + - True - True tag_store False 1 @@ -826,10 +745,10 @@ - + - + From e5cefa339440180c3729a4b3d25473ee25ac65ef Mon Sep 17 00:00:00 2001 From: Diego Garcia Gangl Date: Wed, 4 May 2022 19:56:24 -0300 Subject: [PATCH 007/288] Comment out liblarch in main window Avoids a version mismatch error with Gtk --- GTG/gtk/browser/main_window.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GTG/gtk/browser/main_window.py b/GTG/gtk/browser/main_window.py index ec81d0caf2..6b4885e432 100644 --- a/GTG/gtk/browser/main_window.py +++ b/GTG/gtk/browser/main_window.py @@ -22,7 +22,7 @@ import datetime import logging import ast -import liblarch_gtk # Just for types +#import liblarch_gtk # Just for types from gi.repository import GObject, Gtk, Gdk, Gio, GLib @@ -717,7 +717,7 @@ def on_expand_all_tasks(self, action, param): """Expand all tasks.""" self.vtree_panes['active'].expand_all() - def on_task_expanded(self, sender: liblarch_gtk.TreeView, path: str): + def on_task_expanded(self, sender, path: str): # For some reason, path is turned from a tuple into a string of a # tuple if type(path) is str: From cfe0c6e09cc1af0a2e23594af9a865835b5a1ddf Mon Sep 17 00:00:00 2001 From: Raidro Manchester Date: Fri, 14 Jan 2022 20:35:59 +0200 Subject: [PATCH 008/288] gtk4: adapt to event controller changes Basically widget is no longer a construct only property, but you use GtkWidget.add_controller. This also makes self. no longer needed as the widget now stores the reference to the controller --- GTG/gtk/browser/main_window.py | 59 ++++++++++++++++++++++------------ GTG/gtk/editor/calendar.py | 5 +-- GTG/gtk/editor/taskview.py | 12 ++++--- 3 files changed, 48 insertions(+), 28 deletions(-) diff --git a/GTG/gtk/browser/main_window.py b/GTG/gtk/browser/main_window.py index 6b4885e432..6243747e67 100644 --- a/GTG/gtk/browser/main_window.py +++ b/GTG/gtk/browser/main_window.py @@ -313,10 +313,12 @@ def init_tags_sidebar(self): self.tagtreeview = self.tv_factory.tags_treeview(self.tagtree) self.tagtreeview.get_selection().connect('changed', self.on_select_tag) - self.tagtree_gesture_single = Gtk.GestureSingle(widget=self.tagtreeview, button=Gdk.BUTTON_SECONDARY) - self.tagtree_gesture_single.connect('begin', self.on_tag_treeview_click_begin) - self.tagtree_key_controller = Gtk.EventControllerKey(widget=self.tagtreeview) - self.tagtree_key_controller.connect('key-pressed', self.on_tag_treeview_key_press_event) + tagtree_gesture_single = Gtk.GestureSingle(button=Gdk.BUTTON_SECONDARY) + tagtree_gesture_single.connect('begin', self.on_tag_treeview_click_begin) + tagtree_key_controller = Gtk.EventControllerKey() + tagtree_key_controller.connect('key-pressed', self.on_tag_treeview_key_press_event) + self.tagtreeview.add_controller(tagtree_gesture_single) + self.tagtreeview.add_controller(tagtree_key_controller) self.tagtreeview.connect('node-expanded', self.on_tag_expanded) self.tagtreeview.connect('node-collapsed', self.on_tag_collapsed) @@ -408,32 +410,47 @@ def _init_signal_connections(self): self.connect('size-allocate', self.on_size_allocate) # # Active tasks TreeView - # self.vtree_panes['active'].connect('row-activated', self.on_edit_active_task) - # self.vtree_panes['active'].connect('cursor-changed', self.on_cursor_changed) - # tsk_treeview_btn_press = self.on_task_treeview_click_begin - # self.active_pane_gesture_single = Gtk.GestureSingle(widget=self.vtree_panes['active'], button=Gdk.BUTTON_SECONDARY, - # propagation_phase=Gtk.PropagationPhase.CAPTURE) - # self.active_pane_gesture_single.connect('begin', tsk_treeview_btn_press) + # active_pane_gesture_single = Gtk.GestureSingle( + # button=Gdk.BUTTON_SECONDARY, propagation_phase=Gtk.PropagationPhase.CAPTURE + # ) + # active_pane_gesture_single.connect('begin', tsk_treeview_btn_press) # task_treeview_key_press = self.on_task_treeview_key_press_event - # self.active_pane_key_controller = Gtk.EventControllerKey(widget=self.vtree_panes['active']) - # self.active_pane_key_controller.connect('key-pressed', task_treeview_key_press) + # active_pane_key_controller = Gtk.EventControllerKey() + # active_pane_key_controller.connect('key-pressed', task_treeview_key_press) + # self.vtree_panes['active'].add_controller(active_pane_gesture_single) + # self.vtree_panes['active'].add_controller(active_pane_key_controller) # self.vtree_panes['active'].connect('node-expanded', self.on_task_expanded) # self.vtree_panes['active'].connect('node-collapsed', self.on_task_collapsed) # # Workview tasks TreeView - # self.vtree_panes['workview'].connect('row-activated', self.on_edit_active_task) - # self.vtree_panes['workview'].connect('cursor-changed', self.on_cursor_changed) - # tsk_treeview_btn_press = self.on_task_treeview_click_begin - # self.workview_pane_gesture_single = Gtk.GestureSingle(widget=self.vtree_panes['workview'], button=Gdk.BUTTON_SECONDARY, - # propagation_phase=Gtk.PropagationPhase.CAPTURE) - # self.workview_pane_gesture_single.connect('begin', tsk_treeview_btn_press) + # workview_pane_gesture_single = Gtk.GestureSingle( + # button=Gdk.BUTTON_SECONDARY, propagation_phase=Gtk.PropagationPhase.CAPTURE + # ) + # workview_pane_gesture_single.connect('begin', tsk_treeview_btn_press) # task_treeview_key_press = self.on_task_treeview_key_press_event - # self.workview_pane_key_controller = Gtk.EventControllerKey(widget=self.vtree_panes['workview']) - # self.workview_pane_key_controller.connect('key-pressed', task_treeview_key_press) + # workview_pane_key_controller = Gtk.EventControllerKey() + # workview_pane_key_controller.connect('key-pressed', task_treeview_key_press) + # self.vtree_panes['workview'].add_controller(workview_pane_gesture_single) + # self.vtree_panes['workview'].add_controller(workview_pane_key_controller) # self.vtree_panes['workview'].set_col_visible('startdate', False) + # Closed tasks Treeview + # self.vtree_panes['closed'].connect('row-activated', self.on_edit_done_task) + # I did not want to break the variable and there was no other + # option except this name:(Nimit) + # clsd_tsk_btn_prs = self.on_closed_task_treeview_click_begin + # closed_pane_gesture_single = Gtk.GestureSingle( + # button=Gdk.BUTTON_SECONDARY, propagation_phase=Gtk.PropagationPhase.CAPTURE + # ) + # closed_pane_gesture_single.connect('begin', clsd_tsk_btn_prs) + # clsd_tsk_key_prs = self.on_closed_task_treeview_key_press_event + # closed_pane_key_controller = Gtk.EventControllerKey() + # closed_pane_key_controller.connect('key-pressed', clsd_tsk_key_prs) + # self.vtree_panes['closed'].add_controller(closed_pane_gesture_single) + # self.vtree_panes['closed'].add_controller(closed_pane_key_controller) + # self.vtree_panes['closed'].connect('cursor-changed', self.on_cursor_changed) # # Closed tasks Treeview # self.vtree_panes['closed'].connect('row-activated', self.on_edit_done_task) # # I did not want to break the variable and there was no other @@ -1040,7 +1057,7 @@ def on_closed_task_treeview_key_press_event(self, controller, keyval, keycode, s def on_add_task(self, widget=None): tags = [tag for tag in self.get_selected_tags(nospecial=True)] - + task = self.req.new_task(tags=tags, newtask=True) uid = task.get_id() diff --git a/GTG/gtk/editor/calendar.py b/GTG/gtk/editor/calendar.py index b0ac63f25e..e28503d94f 100644 --- a/GTG/gtk/editor/calendar.py +++ b/GTG/gtk/editor/calendar.py @@ -111,8 +111,9 @@ def show(self): if self.get_decorated(): self.__window.connect("delete-event", self.close_calendar) else: - self.__window_gesture_single = Gtk.GestureSingle(widget=self.__window) - self.__window_gesture_single.connect('begin', self.__focus_out) + window_gesture_single = Gtk.GestureSingle() + window_gesture_single.connect('begin', self.__focus_out) + self.__window.add_controller(window_gesture_single) self.__sigid = self.__calendar.connect("day-selected", self.__day_selected, "RealDate",) diff --git a/GTG/gtk/editor/taskview.py b/GTG/gtk/editor/taskview.py index 8b60b6ad83..4282feabec 100644 --- a/GTG/gtk/editor/taskview.py +++ b/GTG/gtk/editor/taskview.py @@ -146,11 +146,13 @@ def __init__(self, req: Requester, clipboard) -> None: # Signals and callbacks self.id_modified = self.buffer.connect('changed', self.on_modified) - self.motion_controller = Gtk.EventControllerMotion(widget=self) - self.motion_controller.connect('motion', self.on_mouse_move) - self.key_controller = Gtk.EventControllerKey(widget=self) - self.key_controller.connect('key-pressed', self.on_key_pressed) - self.key_controller.connect('key-released', self.on_key_released) + motion_controller = Gtk.EventControllerMotion() + motion_controller.connect('motion', self.on_mouse_move) + self.add_controller(motion_controller) + key_controller = Gtk.EventControllerKey() + key_controller.connect('key-pressed', self.on_key_pressed) + key_controller.connect('key-released', self.on_key_released) + self.add_controller(key_controller) def on_modified(self, buffer: Gtk.TextBuffer) -> None: From 2e7560142af48715fc15c8fbf73026a1ddf9895e Mon Sep 17 00:00:00 2001 From: Raidro Manchester Date: Sat, 23 Oct 2021 19:02:01 +0300 Subject: [PATCH 009/288] gtk4: adapt to focus changes This is mainly removing the stupid can_focus>False that people keep putting into their UI files. First, it has a different meaning in GTK4 (you usually dont need it). And you don't need it in 99% of cases in GTK3, but Glade decided to throw it down anywhere, so many UI files are full of this useless property Default focus has changed, instead of the billion has/is/can focus properties you set a property on the GtkWindow, this will be accoutned for later when the main_window ui file will actually contain the window --- GTG/gtk/data/calendar.ui | 3 -- GTG/gtk/data/general_preferences.ui | 26 ----------- GTG/gtk/data/main_window.ui | 32 -------------- GTG/gtk/data/modify_tags.ui | 8 +--- GTG/gtk/data/plugins.ui | 12 ----- GTG/gtk/data/preferences.ui | 7 --- GTG/gtk/data/tag_editor.ui | 15 ------- GTG/gtk/data/task_editor.ui | 68 ----------------------------- GTG/gtk/editor/taskview.py | 2 +- 9 files changed, 2 insertions(+), 171 deletions(-) diff --git a/GTG/gtk/data/calendar.ui b/GTG/gtk/data/calendar.ui index a7cf018832..f4ade0bbab 100644 --- a/GTG/gtk/data/calendar.ui +++ b/GTG/gtk/data/calendar.ui @@ -2,7 +2,6 @@ - False GDK_STRUCTURE_MASK | GDK_PROXIMITY_OUT_MASK False True @@ -12,7 +11,6 @@ - False 12 12 12 @@ -23,7 +21,6 @@ - False 8 True diff --git a/GTG/gtk/data/general_preferences.ui b/GTG/gtk/data/general_preferences.ui index c46c4dcc5d..7102cdfb1b 100644 --- a/GTG/gtk/data/general_preferences.ui +++ b/GTG/gtk/data/general_preferences.ui @@ -8,20 +8,16 @@ 10 - False never 450 - False start - False vertical - False start 12 12 @@ -34,26 +30,22 @@ - False 12 12 8 8 - False center vertical - False Show description preview 0 - False Show a task excerpt next to each task in the Task Browser 0 - - - - - Tags - - + + False + start + pan-down-symbolic + 1 + + + + + + vertical - - vertical - - - center - - - 6 - - - 40 - False - Search here - - - - - - Save Search - win.save_search - - - - - - + + False - - True + + False + 75 vertical - - crossfade + + True + 10 + 10 + bottom + False + False - - open_view - Open + - + + - - - - - actionable_view - Actionable - - - - - - - - - - - - closed_view - Closed - - - - - + + + Tags + - + + vertical - - True - Ex.: "Buy a new printer for @Initech tags:equipment,office start:monday due:soon" - 10 - 10 - 7 - 7 - Quickly create tasks here - GTK_INPUT_HINT_SPELLCHECK | GTK_INPUT_HINT_NONE - True - - - + + center + + + 6 + + + 40 + Search here + + + + + + Save Search + win.save_search + + + + - - - - - - - - - - - stack - - - - - Create a new task - center - app.new_task - - - list-add-symbolic - 1 - - - - - - - True - main_menu - - - open-menu-symbolic - - - - - - - Activate Search Entry - center - win.search - - - edit-find-symbolic - 1 - - - - - - - start - - - Start Tomorrow - False - True - Defer selected task(s) to tomorrow. Useful if you are out of focus or need additional time. - win.start_tomorrow - - - True - True - - True - PANGO_ELLIPSIZE_MIDDLE - 9 - Start Tomorrow + + True + vertical + + + crossfade + + + open_view + Open + + + + + + + + + + + + actionable_view + Actionable + + + + + + + + + + + + closed_view + Closed + + + + + + + + + + + - - True - appointment-new-symbolic + + + + True + Ex.: "Buy a new printer for @Initech tags:equipment,office start:monday due:soon" + 10 + 10 + 7 + 7 + Quickly create tasks here + GTK_INPUT_HINT_SPELLCHECK | GTK_INPUT_HINT_NONE + True + + + + + - - - False - True - defer_menu - - - False - start - pan-down-symbolic - 1 - - - - - - - + From 3b2fb7e21f881a35a779a7672c50ae93a475b8d3 Mon Sep 17 00:00:00 2001 From: Raidro Manchester Date: Sun, 24 Oct 2021 17:19:57 +0300 Subject: [PATCH 027/288] gtk4: editor: use composite template Gtk.Builder.connect_signals is gone, the replacement needs to be implemented by the language binding, for PyGObject it isn't. Composite Templates allow easy connecting of signals, to avoid connect_signals we use composite templates The part with the dict of lambdas got expanded quite a lot, maybe I should have used a for loop that calls the Gtk.Template.Callback() decorator on them? However I don't know if callbacks maybe need a reference of them to exist to function --- GTG/gtk/application.py | 4 +- GTG/gtk/data/task_editor.ui | 8 +- GTG/gtk/editor/editor.py | 236 ++++++++++++++++++------------------ 3 files changed, 123 insertions(+), 125 deletions(-) diff --git a/GTG/gtk/application.py b/GTG/gtk/application.py index 9b27cbf828..afbf08bad1 100644 --- a/GTG/gtk/application.py +++ b/GTG/gtk/application.py @@ -444,7 +444,7 @@ def delete_editor_task(self, action, params): if task.is_new(): self.close_task(task.get_id()) else: - self.delete_tasks([task.get_id()], editor.window) + self.delete_tasks([task.get_id()], editor) def open_tags_popup_in_editor(self, action, params): """Callback to open the tags popup in the focused task editor.""" @@ -586,7 +586,7 @@ def get_active_editor(self): """Get focused task editor window.""" for editor in self.open_tasks.values(): - if editor.window.is_active(): + if editor.is_active(): return editor def close_task(self, tid): diff --git a/GTG/gtk/data/task_editor.ui b/GTG/gtk/data/task_editor.ui index f3bebb51d1..924254950b 100644 --- a/GTG/gtk/data/task_editor.ui +++ b/GTG/gtk/data/task_editor.ui @@ -242,7 +242,7 @@ 0 0 True - + @@ -282,7 +282,7 @@ - + @@ -314,7 +314,7 @@ - + closeddate_entry False diff --git a/GTG/gtk/editor/editor.py b/GTG/gtk/editor/editor.py index 4153196773..c5994b6d08 100644 --- a/GTG/gtk/editor/editor.py +++ b/GTG/gtk/editor/editor.py @@ -50,9 +50,34 @@ log = logging.getLogger(__name__) -class TaskEditor: - - EDITOR_UI_FILE = os.path.join(UI_DIR, "task_editor.ui") +@Gtk.Template(filename=os.path.join(UI_DIR, "task_editor.ui")) +class TaskEditor(Gtk.Window): + __gtype_name__ = "TaskEditor" + + editormenu = Gtk.Template.Child("editor_menu") + donebutton = Gtk.Template.Child("mark_as_done") + undonebutton = Gtk.Template.Child("mark_as_undone") + add_subtask = Gtk.Template.Child() + tag_store = Gtk.Template.Child() + parent_button = Gtk.Template.Child("parent") + scrolled = Gtk.Template.Child("scrolledtask") + + # Closed date + closed_box = Gtk.Template.Child() + closed_popover = Gtk.Template.Child() + closed_entry = Gtk.Template.Child() + closed_calendar = Gtk.Template.Child() + + # Start date + start_box = Gtk.Template.Child() + start_popover = Gtk.Template.Child() + start_entry = Gtk.Template.Child("startdate_entry") + start_calendar = Gtk.Template.Child("calendar_start") + + # Due date + due_popover = Gtk.Template.Child() + due_entry = Gtk.Template.Child("duedate_entry") + due_calendar = Gtk.Template.Child("calendar_due") def __init__(self, requester, @@ -65,35 +90,13 @@ def __init__(self, app is the view manager thisisnew is True when a new task is created and opened """ + super().__init__() self.req = requester self.app = app self.browser_config = self.req.get_config('browser') self.config = self.req.get_task_config(task.get_id()) self.time = None self.clipboard = clipboard - self.builder = Gtk.Builder() - self.builder.add_from_file(self.EDITOR_UI_FILE) - self.editormenu = self.builder.get_object("editor_menu") - self.donebutton = self.builder.get_object("mark_as_done") - self.undonebutton = self.builder.get_object("mark_as_undone") - self.add_subtask = self.builder.get_object("add_subtask") - self.tag_store = self.builder.get_object("tag_store") - self.parent_button = self.builder.get_object("parent") - - # Closed date - self.closed_popover = self.builder.get_object("closed_popover") - self.closed_entry = self.builder.get_object("closeddate_entry") - self.closed_calendar = self.builder.get_object("calendar_closed") - - # Start date - self.start_popover = self.builder.get_object("start_popover") - self.start_entry = self.builder.get_object("startdate_entry") - self.start_calendar = self.builder.get_object("calendar_start") - - # Due date - self.due_popover = self.builder.get_object("due_popover") - self.due_entry = self.builder.get_object("duedate_entry") - self.due_calendar = self.builder.get_object("calendar_due") # Recurrence self.recurring_menu = RecurringMenu(self.req, task.tid, self.builder) @@ -104,57 +107,7 @@ def __init__(self, new_task = Task2(task.tid, task.get_title()) self.app.ds.tasks.add(new_task) - - # Create our dictionary and connect it - dic = { - "on_tags_popover": self.open_tags_popover, - "on_tag_toggled": self.on_tag_toggled, - - "on_move": self.on_move, - - "set_recurring_term_every_day": self.set_recurring_term_every_day, - "set_recurring_term_every_otherday": self.set_recurring_term_every_otherday, - "set_recurring_term_every_week": self.set_recurring_term_every_week, - "set_recurring_term_every_month": self.set_recurring_term_every_month, - "set_recurring_term_every_year": self.set_recurring_term_every_year, - "set_recurring_term_week_day": self.set_recurring_term_week_day, - "set_recurring_term_calender_month": self.set_recurring_term_month, - "set_recurring_term_calender_year": self.set_recurring_term_year, - "toggle_recurring_status": self.toggle_recurring_status, - "on_repeat_icon_toggled": self.on_repeat_icon_toggled, - - "show_popover_start": self.show_popover_start, - "startingdate_changed": lambda w: self.date_changed( - w, GTGCalendar.DATE_KIND_START), - "startdate_cleared": lambda w: self.on_date_cleared( - w, GTGCalendar.DATE_KIND_START), - "startdate_focus_out": lambda w, e: self.date_focus_out( - w, e, GTGCalendar.DATE_KIND_START), - - "show_popover_due": self.show_popover_due, - "duedate_changed": lambda w: self.date_changed( - w, GTGCalendar.DATE_KIND_DUE), - "duedate_now_selected": lambda w: self.on_duedate_fuzzy( - w, Date.now()), - "duedate_soon_selected": lambda w: self.on_duedate_fuzzy( - w, Date.soon()), - "duedate_someday_selected": lambda w: self.on_duedate_fuzzy( - w, Date.someday()), - "duedate_cleared": lambda w: self.on_date_cleared( - w, GTGCalendar.DATE_KIND_DUE), - "duedate_focus_out": lambda w, e: self.date_focus_out( - w, e, GTGCalendar.DATE_KIND_DUE), - - "show_popover_closed": self.show_popover_closed, - "closeddate_changed": lambda w: self.date_changed( - w, GTGCalendar.DATE_KIND_CLOSED), - "closeddate_focus_out": lambda w, e: self.date_focus_out( - w, e, GTGCalendar.DATE_KIND_CLOSED), - } - - self.window = self.builder.get_object("TaskEditor") - self.builder.connect_signals(dic) - self.window.set_application(app) + self.set_application(app) if task.has_parent(): self.parent_button.set_label(_('Open Parent')) @@ -174,8 +127,7 @@ def __init__(self, # Removing the Normal textview to replace it by our own # So don't try to change anything with glade, this is a home-made # widget - textview = self.builder.get_object("textview") - scrolled = self.builder.get_object("scrolledtask") + textview = self.get_template_child("textview") scrolled.set_child(None) self.textview = TaskView(self.req, self.clipboard) self.textview.set_vexpand(True) @@ -245,7 +197,7 @@ def __init__(self, self.task.set_to_keep() self.textview.buffer.end_not_undoable_action() - self.window.connect("destroy", self.destruction) + self.connect("destroy", self.destruction) # Connect search field to tags popup self.tags_entry = self.builder.get_object("tags_entry") @@ -266,12 +218,12 @@ def __init__(self, self.init_dimensions() - self.window.insert_action_group('app', app) - self.window.insert_action_group('win', app.browser) + self.insert_action_group('app', app) + self.insert_action_group('win', app.browser) self.textview.set_editable(True) - self.window.set_transient_for(self.app.browser) - self.window.show() + self.set_transient_for(self.app.browser) + self.show() def tag_added(self, name): @@ -288,6 +240,7 @@ def tag_removed(self, name): t.remove_tag(name) + @Gtk.Template.Callback() def show_popover_start(self, widget, event): """Open the start date calendar popup.""" @@ -300,6 +253,7 @@ def show_popover_start(self, widget, event): self.start_popover.popup() + @Gtk.Template.Callback() def show_popover_due(self, widget, popover): """Open the due date calendar popup.""" @@ -317,6 +271,7 @@ def show_popover_due(self, widget, popover): self.due_popover.popup() + @Gtk.Template.Callback() def show_popover_closed(self, widget, popover): """Open the closed date calendar popup.""" @@ -335,10 +290,10 @@ def open_tags_popover(self): tags = self.req.get_tag_tree().get_all_nodes() used_tags = self.task.get_tags() - - special_tags = ["search", - "gtg-tags-all", - "gtg-tags-none", + + special_tags = ["search", + "gtg-tags-all", + "gtg-tags-none", "gtg-tags-sep"] for tagname in tags: @@ -383,6 +338,7 @@ def set_dismissable_in_menu(self, dismissable): return i += 1 + @Gtk.Template.Callback() def on_tag_toggled(self, widget, path, column): """We toggle by tag_row variable. tag_row is meant to be a tuple (is_used, tagname)""" @@ -395,50 +351,60 @@ def on_tag_toggled(self, widget, path, column): TODO(jakubbrindza): Add else case that will remove tag. """ + @Gtk.Template.Callback() def on_repeat_icon_toggled(self, widget): """ Reset popup stack to the first page every time you open it """ if widget.get_active(): self.recurring_menu.reset_stack() + @Gtk.Template.Callback() def toggle_recurring_status(self, widget): self.recurring_menu.update_repeat_checkbox() self.refresh_editor() + @Gtk.Template.Callback() def set_recurring_term_every_day(self, widget): self.recurring_menu.set_selected_term('day') self.recurring_menu.update_term() self.refresh_editor() + @Gtk.Template.Callback() def set_recurring_term_every_otherday(self, widget): self.recurring_menu.set_selected_term('other-day') self.recurring_menu.update_term() self.refresh_editor() + @Gtk.Template.Callback() def set_recurring_term_every_week(self, widget): self.recurring_menu.set_selected_term('week') self.recurring_menu.update_term() self.refresh_editor() + @Gtk.Template.Callback() def set_recurring_term_every_month(self, widget): self.recurring_menu.set_selected_term('month') self.recurring_menu.update_term() self.refresh_editor() + @Gtk.Template.Callback() def set_recurring_term_every_year(self, widget): self.recurring_menu.set_selected_term('year') self.recurring_menu.update_term() self.refresh_editor() + @Gtk.Template.Callback() def set_recurring_term_week_day(self, widget): self.recurring_menu.set_selected_term(widget.get_property("name")) self.recurring_menu.update_term() self.refresh_editor() + @Gtk.Template.Callback() def set_recurring_term_month(self, widget): self.recurring_menu.set_selected_term(str(widget.get_date()[2])) self.recurring_menu.update_term() self.refresh_editor() + @Gtk.Template.Callback() def set_recurring_term_year(self, widget): month = str(widget.get_date()[1] + 1) day = str(widget.get_date()[2]) @@ -450,6 +416,50 @@ def set_recurring_term_year(self, widget): self.recurring_menu.update_term() self.refresh_editor() + @Gtk.Template.Callback() + def startingdate_changed(self, w): + self.date_changed(w, GTGCalendar.DATE_KIND_START) + + @Gtk.Template.Callback() + def startdate_cleared(self, w): + self.on_date_cleared(w, GTGCalendar.DATE_KIND_START) + + @Gtk.Template.Callback() + def startdate_focus_out(self, w, e): + self.date_focus_out(w, e, GTGCalendar.DATE_KIND_START) + + @Gtk.Template.Callback() + def duedate_changed(self, w): + self.date_changed(w, GTGCalendar.DATE_KIND_DUE) + + @Gtk.Template.Callback() + def duedate_now_selected(self, w): + self.on_duedate_fuzzy(w, Date.now()) + + @Gtk.Template.Callback() + def duedate_soon_selected(self, w): + self.on_duedate_fuzzy(w, Date.soon()) + + @Gtk.Template.Callback() + def duedate_someday_selected(self, w): + self.on_duedate_fuzzy(w, Date.someday()) + + @Gtk.Template.Callback() + def duedate_cleared(self, w): + self.on_date_cleared(w, GTGCalendar.DATE_KIND_DUE) + + @Gtk.Template.Callback() + def duedate_focus_out(self, w, e): + self.date_focus_out(w, e, GTGCalendar.DATE_KIND_DUE) + + @Gtk.Template.Callback() + def closeddate_changed(self, w): + self.date_changed(w, GTGCalendar.DATE_KIND_CLOSED) + + @Gtk.Template.Callback() + def closeddate_focus_out(self, w, e): + self.date_focus_out(w, e, GTGCalendar.DATE_KIND_CLOSED) + def search_function(self, model, column, key, iter, *search_data): """Callback when searching in the tags popup.""" @@ -474,7 +484,7 @@ def init_dimensions(self): if size and len(size) == 2: try: - self.window.resize(int(size[0]), int(size[1])) + self.resize(int(size[0]), int(size[1])) except ValueError: log.warning('Invalid size configuration for task %s: %s', self.task.get_id(), size) @@ -490,7 +500,7 @@ def init_dimensions(self): log.warning('Invalid position configuration for task %s:%s', self.task.get_id(), position) else: - gdk_window = self.window.get_window() + gdk_window = self.get_window() if gdk_window is None: log.debug("Using default display to position editor window") display = Gdk.Display.get_default() @@ -510,13 +520,13 @@ def init_dimensions(self): assert isinstance(y, int) if can_move: - width, height = self.window.get_size() + width, height = self.get_size() # Clamp positions to current screen size x = min(x, screen_size.width - width) y = min(y, screen_size.height - height) - self.window.move(x, y) + self.move(x, y) # Can be called at any time to reflect the status of the Task # Refresh should never interfere with the TaskView. @@ -525,15 +535,15 @@ def init_dimensions(self): # Refreshtext is whether or not we should refresh the TaskView # (doing it all the time is dangerous if the task is empty) def refresh_editor(self, title=None, refreshtext=False): - if self.window is None: + if self is None: return to_save = False # title of the window if title: - self.window.set_title(title) + self.set_title(title) to_save = True else: - self.window.set_title(self.task.get_title()) + self.set_title(self.task.get_title()) status = self.task.get_status() if status == Task.STA_DISMISSED: @@ -559,11 +569,11 @@ def refresh_editor(self, title=None, refreshtext=False): # Refreshing the status bar labels and date boxes if status in [Task.STA_DISMISSED, Task.STA_DONE]: - self.builder.get_object("start_box").hide() - self.builder.get_object("closed_box").show() + self.start_box.hide() + self.closed_box.show() else: - self.builder.get_object("closed_box").hide() - self.builder.get_object("start_box").show() + self.closed_box.hide() + self.start_box.show() # refreshing the start date field startdate = self.task.get_start_date() @@ -641,7 +651,7 @@ def refresh_day_left(self): txt = ngettext("Due yesterday!", "Was %(days)d days ago", abs_result) % {'days': abs_result} - style_context = self.window.get_style_context() + style_context = self.get_style_context() color = style_context.get_color().to_color() self.dayleft_label.set_markup( f"{txt}") @@ -946,21 +956,12 @@ def light_save(self): if tosave: self.save() - def present(self): - # This tries to bring the Task Editor to the front. - # If TaskEditor is a "utility" window type, this doesn't work on X11, - # it only works on GNOME's Wayland session, unless the child is closed. - # This is partly why we use self.close() in various places elsewhere. - self.window.present() - - def get_position(self): - return self.window.get_position() - + @Gtk.Template.Callback() def on_move(self, widget, event): """ Save position and size of window """ - self.config.set('position', list(self.window.get_position())) - self.config.set('size', list(self.window.get_size())) + self.config.set('position', list(self.get_position())) + self.config.set('size', list(self.get_size())) def on_textview_focus_in(self, widget, event): self.app.browser.toggle_delete_accel(False) @@ -972,9 +973,9 @@ def on_textview_focus_out(self, widget, event): def close(self, action=None, param=None): # We should also destroy the whole taskeditor object. - if self.window: - self.window.destroy() - self.window = None + if self: + self.destroy() + self = None def destruction(self, _=None): """Callback when destroying the window.""" @@ -997,9 +998,6 @@ def destruction(self, _=None): except KeyError: log.debug('Task %s was already removed from the open list', tid) - def get_builder(self): - return self.builder - def get_task(self): return self.task @@ -1007,5 +1005,5 @@ def get_textview(self): return self.textview def get_window(self): - return self.window + return self # ----------------------------------------------------------------------------- From 95fb221fbd64b0f23b215fddb9733410b7e1ef80 Mon Sep 17 00:00:00 2001 From: Raidro Manchester Date: Tue, 9 Nov 2021 12:26:29 +0200 Subject: [PATCH 028/288] gtk4: main_window: make quickadd_field default focus Adaptation to the change in default focus API, done now as now the window object is included in the UI file. --- GTG/gtk/data/main_window.ui | 1 + 1 file changed, 1 insertion(+) diff --git a/GTG/gtk/data/main_window.ui b/GTG/gtk/data/main_window.ui index 0d8dfcab4b..98e078408e 100644 --- a/GTG/gtk/data/main_window.ui +++ b/GTG/gtk/data/main_window.ui @@ -255,6 +255,7 @@