From ce000548375ac7d4d1cd3e0ee1811d8a5b09db5b Mon Sep 17 00:00:00 2001 From: evinjbobby Date: Wed, 4 Dec 2024 01:25:12 +0100 Subject: [PATCH 1/3] removed some unnecessary comments --- dtool_lookup_gui/views/main_window.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/dtool_lookup_gui/views/main_window.py b/dtool_lookup_gui/views/main_window.py index b671899..7677418 100644 --- a/dtool_lookup_gui/views/main_window.py +++ b/dtool_lookup_gui/views/main_window.py @@ -1388,32 +1388,14 @@ async def _get_manifest(): def on_remove_tag(self, button, tag): dataset.delete_tag(tag) asyncio.create_task(self._update_dataset_view(dataset)) - # asyncio.create_task(_get_tags()) def on_add_tag(self,button, entry): tag = entry.get_text() dataset.put_tag(tag) asyncio.create_task(self._update_dataset_view(dataset)) - # asyncio.create_task(_get_tags()) - - # def on_remove_tag(self, button, tag): - # asyncio.create_task(_remove_tag_async(self,button, tag)) - - # async def _remove_tag_async(self, button, tag): - # dataset.delete_tag(tag) - # await self._show_dataset_details(dataset) - - # def on_add_tag(self, button, entry): - # asyncio.create_task(_add_tag_async(self,button, entry)) - - # async def _add_tag_async(self, button, entry): - # tag = entry.get_text() - # dataset.put_tag(tag) - # await self._show_dataset_details(dataset) async def _get_tags(): tags = await dataset.get_tags() - # print("tags",tags) # Remove the widgets of previous datasets already present for child in self.show_tags_box.get_children(): From 4106ca2df437ee83d14b85997b6c75cc005054da Mon Sep 17 00:00:00 2001 From: evinjbobby Date: Thu, 5 Dec 2024 15:06:49 +0100 Subject: [PATCH 2/3] added do actions --- dtool_lookup_gui/views/main_window.py | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/dtool_lookup_gui/views/main_window.py b/dtool_lookup_gui/views/main_window.py index 7677418..ebf8225 100644 --- a/dtool_lookup_gui/views/main_window.py +++ b/dtool_lookup_gui/views/main_window.py @@ -376,6 +376,19 @@ def __init__(self, *args, **kwargs): get_item_action.connect("activate", self.do_get_item) self.add_action(get_item_action) + # put tags + put_tags_variant = GLib.Variant.new_string('dummy') + put_tags_action = Gio.SimpleAction.new("put-tags", put_tags_variant.get_type()) + put_tags_action.connect("activate", self.do_put_tags) + self.add_action(put_tags_action) + + # put annotations + # put_annotations_variant = GLib.Variant.new_string('dummy') + put_annotations_action = Gio.SimpleAction.new("put-annotations",GLib.VariantType.new("(ss)")) # Tuple of two strings + + put_annotations_action.connect("activate", self.do_put_annotations) + self.add_action(put_annotations_action) + # refresh view refresh_view_action = Gio.SimpleAction.new("refresh-view") refresh_view_action.connect("activate", self.do_refresh_view) @@ -492,6 +505,19 @@ def do_show_previous_page(self, action, value): page_index = self.search_state.previous_page self._show_page(page_index) + # put tags action + def do_put_tags(self, action, value): + """Put tags on the selected dataset.""" + tags = value.get_string() + search_text = value.get_string() + self._put_tags(tags) + + # put annotations action + def do_put_annotations(self, action, value): + """Put annotations on the selected dataset.""" + key, value = parameter.unpack() + self._put_annotations(key,value) + # other actions def do_get_item(self, action, value): """"Copy currently selected manifest item in currently selected dataset to specified destination.""" @@ -1112,6 +1138,22 @@ def _search(self, search_text, on_show=None): self.search_state.reset_pagination() # self.search_state.current_page = 1 self._refresh_datasets(on_show=on_show) + + # put tags function for action + def _put_tags(self, tags): + """Put tags on the selected dataset.""" + dataset = self.dataset_list_box.get_selected_row().dataset + dataset.put_tags(tags) + asyncio.create_task(self._update_dataset_view(dataset)) + + + # put annotations function for action + def _put_annotations(self, key,value): + """Put annotations on the selected dataset.""" + dataset = self.dataset_list_box.get_selected_row().dataset + dataset.put_annotation(annotation_name=key, annotation=value) + asyncio.create_task(self._update_dataset_view(dataset)) + def _refresh_datasets(self, on_show=None): """Reset dataset list, show spinner, and kick off async task for retrieving dataset entries.""" From 470a321c35f15e4715968dc7f225331ddf055859 Mon Sep 17 00:00:00 2001 From: Johannes Laurin Hoermann Date: Thu, 5 Dec 2024 15:33:09 +0100 Subject: [PATCH 3/3] MAINT: fixed actions --- dtool_lookup_gui/views/main_window.py | 43 +++++++++++++-------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/dtool_lookup_gui/views/main_window.py b/dtool_lookup_gui/views/main_window.py index ebf8225..3fa5bcf 100644 --- a/dtool_lookup_gui/views/main_window.py +++ b/dtool_lookup_gui/views/main_window.py @@ -378,15 +378,14 @@ def __init__(self, *args, **kwargs): # put tags put_tags_variant = GLib.Variant.new_string('dummy') - put_tags_action = Gio.SimpleAction.new("put-tags", put_tags_variant.get_type()) - put_tags_action.connect("activate", self.do_put_tags) + put_tags_action = Gio.SimpleAction.new("put-tag", put_tags_variant.get_type()) + put_tags_action.connect("activate", self.do_put_tag) self.add_action(put_tags_action) # put annotations - # put_annotations_variant = GLib.Variant.new_string('dummy') - put_annotations_action = Gio.SimpleAction.new("put-annotations",GLib.VariantType.new("(ss)")) # Tuple of two strings - - put_annotations_action.connect("activate", self.do_put_annotations) + put_annotations_variant_type = GLib.VariantType.new("(ss)") # Tuple of two strings + put_annotations_action = Gio.SimpleAction.new("put-annotation", put_annotations_variant_type) + put_annotations_action.connect("activate", self.do_put_annotation) self.add_action(put_annotations_action) # refresh view @@ -506,17 +505,17 @@ def do_show_previous_page(self, action, value): self._show_page(page_index) # put tags action - def do_put_tags(self, action, value): + def do_put_tag(self, action, value): """Put tags on the selected dataset.""" - tags = value.get_string() - search_text = value.get_string() - self._put_tags(tags) + tag = value.get_string() + self._put_tag(tag) # put annotations action - def do_put_annotations(self, action, value): + def do_put_annotation(self, action, parameter): """Put annotations on the selected dataset.""" key, value = parameter.unpack() - self._put_annotations(key,value) + _logger.debug("Unpacked %s: %s key-value pair from tuple in do_put_annotation") + self._put_annotation(key, value) # other actions def do_get_item(self, action, value): @@ -725,7 +724,6 @@ def on_save_metadata_button_clicked(self, widget): start_iter, end_iter = text_buffer.get_bounds() yaml_content = text_buffer.get_text(start_iter, end_iter, True) - # Check the state of the linting switch before linting if settings.yaml_linting_enabled: # Lint the YAML content if the above condition wasn't met (i.e., linting is enabled) @@ -1140,21 +1138,19 @@ def _search(self, search_text, on_show=None): self._refresh_datasets(on_show=on_show) # put tags function for action - def _put_tags(self, tags): + def _put_tag(self, tags): """Put tags on the selected dataset.""" dataset = self.dataset_list_box.get_selected_row().dataset - dataset.put_tags(tags) + dataset.put_tag(tags) asyncio.create_task(self._update_dataset_view(dataset)) - # put annotations function for action - def _put_annotations(self, key,value): + def _put_annotation(self, key, value): """Put annotations on the selected dataset.""" dataset = self.dataset_list_box.get_selected_row().dataset dataset.put_annotation(annotation_name=key, annotation=value) asyncio.create_task(self._update_dataset_view(dataset)) - def _refresh_datasets(self, on_show=None): """Reset dataset list, show spinner, and kick off async task for retrieving dataset entries.""" self.main_stack.set_visible_child(self.main_spinner) @@ -1433,8 +1429,7 @@ def on_remove_tag(self, button, tag): def on_add_tag(self,button, entry): tag = entry.get_text() - dataset.put_tag(tag) - asyncio.create_task(self._update_dataset_view(dataset)) + self.activate_action('put-tag', GLib.Variant.new_string(tag)) async def _get_tags(): tags = await dataset.get_tags() @@ -1520,7 +1515,7 @@ async def on_button_clicked(button): if current_label == "-": # Delete annotation self.annotations_box.remove(box) - # Function to delete the annotation from the dataset + # Function to delete the annotation from the dataset not yet implemented # dataset.delete_annotation(key) elif current_label == "+": # Save new/updated annotation @@ -1528,10 +1523,12 @@ async def on_button_clicked(button): new_value = value_entry.get_text() if new_key and new_value: # Add or update annotation in dataset - dataset.put_annotation(annotation_name=new_key, annotation=new_value) + annotation_tuple = GLib.Variant("(ss)", (new_key, new_value)) + self.activate_action('put-annotation', annotation_tuple) + # dataset.put_annotation(annotation_name=new_key, annotation=new_value) # button.set_label("-") # Change to delete after saving button.set_label("-") # Change to "-" after saving - asyncio.create_task(self._update_dataset_view(dataset)) + # asyncio.create_task(self._update_dataset_view(dataset)) # Update button label on text change def on_text_changed(entry):