Verified Commit 929b7948 authored by tallero's avatar tallero

help stub: finished; constraint search almost completed

parent 059a55b1
......@@ -333,13 +333,18 @@ class Editor(ApplicationWindow):
"""
if event.keyval in modifiers:
return None
print(focused)
focused = window.get_focus()
sidebar_entity_focused = type(focused) == ListBoxRow
sidebar_search_entry_focused = focused == self.sidebar_search_entry
entity_popover_search_entry_focused = type(focused) == SearchEntry()
sidebar_leaflet_focused = self.single_column.get_visible_child_name() == 'sidebar'
print(focused)
if sidebar_search_entry_focused:
pass
if entity_popover_search_entry_focused:
print("test")
pass
elif sidebar_entity_focused or sidebar_leaflet_focused:
if not self.sidebar_search_bar.get_search_mode():
self.sidebar_search_bar.set_search_mode(True)
......
......@@ -226,7 +226,7 @@ class Entity(Stack):
def on_search_done(self, results, error):
try:
listbox = self.entity_popover.label_listbox
listbox = self.entity_popover.results_listbox
listbox.foreach(listbox.remove)
for r in results:
if r['URI'] != self.URI:
......
......@@ -93,7 +93,7 @@ class EntityPopover(PopoverMenu):
else:
self.set_search_placeholder(True)
def on_search_done(self, results, query, *args, **kwargs):
def on_search_done(self, results, error, query, *args, **kwargs):
if query == self.search_entry.get_text():
try:
set_text(self.variable_title, query, query)
......
......@@ -58,6 +58,7 @@ class Open(Window):
constraint_box = Template.Child("constraint_box")
constraint_viewport = Template.Child("constraint_viewport")
constraint_button_box = Template.Child("constraint_button_box")
filters_subtitle = Template.Child("filters_subtitle")
help = Template.Child("help")
help_menu = Template.Child("help_menu")
open_session = Template.Child("open_session")
......@@ -116,6 +117,7 @@ class Open(Window):
def set_search_placeholder(self, value):
self.title.set_visible(value)
self.subtitle.set_visible(value)
self.filters_subtitle.set_visible(value)
self.help.set_visible(value)
self.help_menu.set_visible(not value)
self.select.set_visible(not value)
......@@ -307,7 +309,9 @@ class Open(Window):
return None
self.search_entry.set_text("")
def on_search_done(self, results, query):
def on_search_done(self, results, error, query):
if error:
print("connection error")
if query == self.search_entry.get_text():
self.results_listbox.foreach(self.results_listbox.remove)
......
......@@ -238,15 +238,11 @@
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="variable_title">
<property name="visible">True</property>
<object class="GtkImage">
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">&lt;b&gt;Variable&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
<property name="margin_end">8</property>
<property name="icon_name">list-add-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -255,15 +251,42 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="variable_subtitle">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Record new variable</property>
<property name="xalign">0</property>
<attributes>
<attribute name="font-desc" value="Cantarell 8"/>
</attributes>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="variable_title">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">&lt;b&gt;Variable&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="variable_subtitle">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Record new variable</property>
<property name="xalign">0</property>
<attributes>
<attribute name="font-desc" value="Cantarell 8"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
......
......@@ -177,9 +177,7 @@
<object class="GtkLabel" id="subtitle">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Search for an &lt;a href="https://www.wikidata.org/wiki/Help:Items"&gt;entity&lt;/a&gt; in the database&lt;/b&gt;
or restrict the results among those that satisfy
some filter</property>
<property name="label" translatable="yes">&lt;b&gt;Search for an &lt;a href="https://www.wikidata.org/wiki/Help:Items"&gt;entity&lt;/a&gt; in the database&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="justify">center</property>
<property name="wrap">True</property>
......@@ -205,6 +203,22 @@ some filter</property>
<property name="valign">start</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkLabel" id="filters_subtitle">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">or restrict the results among those that satisfy some filter</property>
<property name="justify">center</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="add_constraint">
<property name="label" translatable="yes">New filter</property>
......@@ -220,7 +234,7 @@ some filter</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
<property name="position">1</property>
</packing>
</child>
</object>
......
......@@ -287,12 +287,16 @@ def search(query, callback, *cb_args, wikidata=None, **kwargs):
from .wikidata import Wikidata
wikidata = Wikidata()
def do_call():
results, error = None, None
results, error = [], None
try:
results = wikidata.search(query)
except Exception as err:
raise err
idle_add(lambda: callback(results, *cb_args, **kwargs))
from requests.exceptions import ConnectionError
if type(err) == ConnectionError:
error = err
else:
raise err
idle_add(lambda: callback(results, error, *cb_args, **kwargs))
thread = Thread(target = do_call)
thread.start()
......
......@@ -231,8 +231,8 @@ class Wikidata:
"Description":clean(r.find(name='span', attrs={'class':'wb-itemlink-description'}).text)} for r in results)
except Exception as e:
results = []
if verbose:
print(e)
#if verbose:
# print(e)
if self.verbose:
pprint(results)
return results
......@@ -9,21 +9,19 @@
<title>Found a bug?</title>
<p>If you suspect you've found a bug in Geary, please <link
href="https://wiki.gnome.org/Apps/Geary/Contact">get in touch</link>
<p>If you suspect you've found a bug in Daty, please <link
href="https://gitlab.gnome.org/World/Daty/issues/boards">get in touch</link>
about it so it can be fixed.</p>
<p>To help diagnose the problem as fast as possible, please include
the following information:</p>
<list>
<item><p>Geary version and installation method (Package? Flathub?
<item><p>Daty version and installation method (Package? Flathub?
Source code?)</p></item>
<item><p>Your desktop (GNOME? KDE? Something else?)</p></item>
<item><p>Your desktop (GNOME? KDE? Windows? Mac?)</p></item>
<item><p>Your operating system and version (Ubuntu 16.04? Fedora
28? Rolled your own?)</p></item>
<item><p>Email provider (Gmail, Yahoo!, Outlook.com, or someone
else?)</p></item>
28? Windows Vista? Rolled your own?)</p></item>
<item><p>Steps to reproduce the bug</p></item>
<item><p>What happened?</p></item>
<item><p>What did you expect to happen?</p></item>
......
......@@ -7,7 +7,7 @@
<link type="next" xref="bugs" />
</info>
<title>Contribute to Daty</title>
<title>Contributing</title>
<p>Want to help improve Daty? There are a number of ways you can
contribute:</p>
......
......@@ -13,8 +13,7 @@
<include href="legal.xml" xmlns="http://www.w3.org/2001/XInclude"/>
</info>
<title><media type="image" mime="image/png" its:translate="no" src="figures/daty.png"></media>
Entity basics</title>
<title>Entities basics</title>
<p>If you are new to <app>daty</app>, these topics will help you with
entities.</p>
......
<page xmlns="http://projectmallard.org/1.0/"
xmlns:its="http://www.w3.org/2005/11/its"
type="topic" style="task"
id="daty-entities-close">
<info>
<link type="guide" xref="daty-entities-basic"/>
<link type="prev" xref="daty-entities-open"/>
<desc>Close an entity.</desc>
<revision pkgversion="1.0" date="2019-02-19" status="review"/>
<credit type="author">
<name>Pellegrino Prevete</name>
<email>pellegrinoprevete@gmail.org</email>
</credit>
<include href="legal.xml" xmlns="http://www.w3.org/2001/XInclude"/>
</info>
<title>Close an entity</title>
<p>To close an entity, hover its row in the <gui>Entities list</gui> with the
mouse and press the <gui>close entity</gui> button
<media type="image" mime="image/png" src="figures/variable-delete.png"/>.</p>
</page>
\ No newline at end of file
<page xmlns="http://projectmallard.org/1.0/"
xmlns:its="http://www.w3.org/2005/11/its"
type="topic" style="task"
id="daty-open-entities">
id="daty-entities-open">
<info>
<link type="guide" xref="daty-entities-basic"/>
<link type="seealso" xref="daty-close-file"/>
<link type="seealso" xref="overview"/>
<link type="next" xref="daty-entities-close"/>
<desc>Open entities to start working on them.</desc>
<revision pkgversion="1.0" date="2019-02-19" status="review"/>
......@@ -27,7 +26,7 @@
<media type="image" mime="image/png" src="figures/open-dialog.png"/>
<p>To search for an entity, type it in the search entry,
<p>To search for an entity by its label, type it in the search entry,
then click on the result to open it in the editor.</p>
<section id="open-multiple-entities">
......@@ -46,4 +45,4 @@
<!-- Insert Image Here -->
</page>
</page>
\ No newline at end of file
......@@ -6,7 +6,7 @@
<info>
<link type="guide" xref="daty-entities-basic"/>
<link type="seealso" xref="daty-close-file"/>
<link type="seealso" xref="overview"/>
<link type="next" xref="daty-entities-open"/>
<desc>A brief overview on entities.</desc>
<revision pkgversion="1.0" date="2019-02-19" status="review"/>
......
......@@ -16,6 +16,6 @@
<title>Filters basics</title>
<p>If you are new to <app>daty</app>, these topics will help you with
entities.</p>
filters.</p>
<links type="topic" groups="first second third fourth fifth sixth" style="2column"/>
</page>
\ No newline at end of file
<page xmlns="http://projectmallard.org/1.0/"
type="guide"
id="daty-filters-delete">
<info>
<link type="guide" xref="daty-filters-basic" groups='third'/>
<link type="previous" xref="daty-filters-new"/>
<desc>How to delete a filter.</desc>
<revision pkgversion="1.0" date="2018-02-20" status="review"/>
<credit type="author">
<name>Pellegrino Prevete</name>
<email>pellegrinoprevete@gmail.org</email>
</credit>
<include href="legal.xml" xmlns="http://www.w3.org/2001/XInclude"/>
</info>
<title>Delete filter</title>
<p>Hover with the mouse the filter you want to delete and press the
<gui>delete filter</gui> button
<media type="image" mime="image/png" src="figures/variable-delete.png"/>
.</p>
</page>
......@@ -3,9 +3,9 @@
id="daty-filters-new">
<info>
<link type="guide" xref="daty-filters-basic"/>
<link type="seealso" xref="daty-open-entities"/>
<link type="seealso" xref="daty-close-entity"/>
<link type="guide" xref="daty-filters-basic" groups='second'/>
<link type="previous" xref="daty-filters-overview"/>
<link type="next" xref="daty-filters-delete"/>
<desc>How to create a filter.</desc>
<revision pkgversion="1.0" date="2018-02-20" status="review"/>
<credit type="author">
......@@ -14,10 +14,59 @@
</credit>
<include href="legal.xml" xmlns="http://www.w3.org/2001/XInclude"/>
</info>
<title>Create a new filter</title>
<p>Click on the <gui>New filter</gui> button. The filter box will then appear
and an empty filter will be displayed.</p>
<title>New filter</title>
<p>Click on the <gui>New filter</gui> button in the <gui>Open entities</gui>
dialog. The filter box will then appear and an empty filter will be displayed.</p>
<media type="image" mime="image/png" src="figures/new-filter.png"/>
<p>Uncompiled or partially compiled filters are displayed with a red background.</p>
<p>Click on the elements of the triplet to set their values through the
<gui>entity selection popover</gui>.</p>
<section id="variables">
<title>Variables</title>
<list>
<item><p>To record a new variable and set it as the value of the element, write
its name in the <gui>entity selection popover</gui> search entry and press the
<gui>Record new variable</gui> button.</p>
<media type="image" mime="image/png" src="figures/new-variable.png"/>
</item>
<item><p>To record a new variable ad set as the default (i.e. its elements will
be the results) for the query, press the <gui>record and set default variable</gui>
button:</p>
<media type="image" mime="image/png" src="figures/set-new-variable-as-default.png"/>
</item>
<item><p>To set an already recorded variable as default, hover its row in
the <gui>entity selection popover</gui> with the mouse and press the <gui>select variable</gui> button
<media type="image" mime="image/png" src="figures/set-variable-as-default.png"/></p>
<note style="tip"><p>Remember: queries that do not contain a selected variable
won't be executed</p></note>
</item>
<item><p>To delete a variable, hover its row in the <gui>entity
selection popover</gui> with the mouse and press the <gui>delete variable</gui> button
<media type="image" mime="image/png" src="figures/variable-delete.png"/></p>
</item>
</list>
</section>
<section id="items">
<title>Items</title>
<p>To select an item, search for its label in the <gui>entity selection
popover</gui> search entry and click on corresponding item in the results.</p>
</section>
<section id="properties">
<title>Properties</title>
<p>To select a property, search for its label in the <gui>entity selection
popover</gui> search entry and click on the corresponding property in the results.</p>
<note style="tip"><p>You can filter properties in search results prefixing
<em>property:</em> to your query (as in <code>property:child</code>)</p></note>
</section>
</page>
......@@ -3,9 +3,8 @@
id="daty-filters-overview">
<info>
<link type="guide" xref="daty-filters-basic"/>
<link type="seealso" xref="daty-open-entities"/>
<link type="seealso" xref="daty-close-entity"/>
<link type="guide" xref="daty-filters-basic" groups='first'/>
<link type="next" xref="daty-filters-new"/>
<desc>A brief introduction to filters.</desc>
<revision pkgversion="1.0" date="2018-02-20" status="review"/>
<credit type="author">
......@@ -36,7 +35,7 @@
<code>
SELECT thing WHERE
thing "has property" "some specific value"
thing "has property" "some specific value"
</code>
<p>So if, as in the above example, we want to search for all the <em>English
......@@ -45,8 +44,8 @@
<code>
SELECT person WHERE
person "has country of citizenship" "England"
person "has occupation" "priest"
person "has country of citizenship" "England"
person "has occupation" "priest"
</code>
<p>In the previous query, the content of the word <code>person</code> is
......@@ -62,13 +61,15 @@
<code>
SELECT grandparent WHERE
parent "has child" "Beethoven"
grandparent "has child" parent
parent "has child" "Beethoven"
grandparent "has child" parent
</code>
<p>Daty provides a simple graphical interface to form SPARQL
queries which uses the <link href="https://query.wikidata.org">
<p>Daty provides a simple graphical interface to form SPARQL queries (i.e.
<em>filters</em>), which uses the <link href="https://query.wikidata.org">
Wikidata query service</link>.</p>
</section>
<p>To learn how to set a filter in daty, go to the next page.<p>
</page>
......@@ -16,13 +16,13 @@
<title>Limitations</title>
<p>Daty is still in early development. Daty uses pywikibot as backend,
thus it does not support lexemes.</p>
<p>Daty is still in early development. Not all confirmed features are available,
editing among others.</p>
<p>Editing will be enabled in the next version.</p>
<p>Also, since it uses pywikibot as backend, it does not support lexemes.</p>
<p>To learn more about the features we're working on and the future
of Daty, please visit Daty's <link
<p>To learn more about the features we are working on and the future
of Daty, please visit project's <link
href="https://gitlab.gnome.org/World/Daty/boards">issues board</link>.</p>
</page>
......@@ -4,8 +4,8 @@
<info>
<link type="guide" xref="index#introduction"/>
<link type="seealso" xref="daty-open-entities"/>
<link type="seealso" xref="daty-close-entity"/>
<link type="seealso" xref="daty-entities-basic"/>
<link type="seealso" xref="daty-filters-basic"/>
<desc>A brief introduction to Daty.</desc>
<revision pkgversion="1.0" date="2018-02-19" status="review"/>
<credit type="author">
......@@ -14,8 +14,7 @@
</credit>
<include href="legal.xml" xmlns="http://www.w3.org/2001/XInclude"/>
</info>
<title><media type="image" mime="image/png" its:translate="no" src="figures/daty.png"></media>
Overview</title>
<title>Overview</title>
<p>Daty is a lightweight <link href="https://wikidata.org">Wikidata</link> editor and reader for the <link href="https://gnome.org">GNOME</link> desktop.</p>
......@@ -60,5 +59,4 @@
<p>The <em>common page</em> will display all properties and values common to the entities you pinned in <em>selection mode</em>.</p>
</section>
</page>
</page>
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment