internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: WeblateOrg/weblate

Issue:
Syntax highlighting of search input
### Describe the issue

1. Go to a screenshot
2. Enter "not found" as the search term
3. A lot of strings appear as search results, most of them not containing anything related to "not found"


If I enter "not" or "found" then fewer results are found compared to "not found".

### I already tried

- [X] I've read and searched [the documentation](https://docs.weblate.org/).
- [X] I've searched for similar issues in this repository.

### Steps to reproduce the behavior

1. Go to a screenshot
2. Enter "not found" as the search term
3. A lot of strings appear as search results, most of them not containing anything related to "not found"

### Expected behavior

Search only lists strings containing "not found"

### Screenshots

![image](https://github.com/WeblateOrg/weblate/assets/69897582/5dcbab51-0de7-4fd8-b454-eb44a08d528e)


### Exception traceback

_No response_

### How do you run Weblate?

weblate.org service

### Weblate versions

_No response_

### Weblate deploy checks

_No response_

### Additional context

_No response_


Discussion:
Use "not found" in this case. Search supports boolean operators, so you search for all strings not containing string found. See https://docs.weblate.org/en/latest/user/search.html#boolean-operators
I see, I'll keep the issue open as a UI bug, as this is not obvious.

Maybe there should be an English representation of what I have searched for, for example: Strings not containing "found", or a mention of the search syntax next to the text box, or a graphical representation of how my query was parsed.

Just looking at the box, I think most users would assume it's a plain text search.
This issue seems to be a good fit for newbie contributors. You are welcome to contribute to Weblate! Don't hesitate to ask any questions you would have while implementing this.

You can learn about how to get started in our [contributors documentation](https://docs.weblate.org/en/latest/contributing/index.html).
I don't think English representation would be useful for possibly long queries. Instead, doing syntax highlighting on the search input would show how it is interpreted.

What I'd like to see:

* Uppercase logical operators upon typing/pasting, so this query would become `NOT found`
* Highlight syntax using PrismJS (which we already use)



Resolving patch:
diff --git a/weblate/utils/forms.py b/weblate/utils/forms.py
--- a/weblate/utils/forms.py
+++ b/weblate/utils/forms.py
@@ -25,6 +25,8 @@ def __init__(self, parser: str = "unit", **kwargs):
             kwargs["label"] = gettext_lazy("Query")
         if "required" not in kwargs:
             kwargs["required"] = False
+        if "widget" not in kwargs:
+            kwargs["widget"] = forms.Textarea(attrs={"cols": None, "rows": 1})
         self.parser = parser
         super().__init__(**kwargs)
 


Test patch:
Repository: WeblateOrg/weblate

Issue:
Expose linked component info in the API
### Describe the problem

Presently the API hides linked components by exposing real repository URL. This was done to make the repo URL usable outside Weblate, but this also complicates editing of the component as the actual setting is not shown.

### Describe the solution you would like

Expose real `repo` (and related) field with the value as is stored in the database. This can break compatibility if somebody relied on the real URL, but will make the API more consistent.

Additionally, add linked_component read-only field so that the actual repo can be easily obtained.

### Describe alternatives you have considered

Adding only linked_component field would allow detecting this is a linked component, without breaking existing `repo` uses. On the other side, there are other fields which are masked this way what makes editing of the linked component via API really tricky.

### Screenshots

_No response_

### Additional context

_No response_


Discussion:

Resolving patch:
diff --git a/weblate/api/serializers.py b/weblate/api/serializers.py
--- a/weblate/api/serializers.py
+++ b/weblate/api/serializers.py
@@ -489,6 +489,12 @@ class ComponentSerializer(RemovableSerializer):
         required=False,
         allow_null=True,
     )
+    linked_component = MultiFieldHyperlinkedIdentityField(
+        view_name="api:component-detail",
+        lookup_field=("linked_component__project__slug", "linked_component__slug"),
+        strip_parts=1,
+        read_only=True,
+    )
 
     task_url = RelatedTaskField(lookup_field="background_task_id")
 
@@ -564,6 +570,7 @@ class Meta:
             "glossary_color",
             "disable_autoshare",
             "category",
+            "linked_component",
         )
         extra_kwargs = {
             "url": {


Test patch:
diff --git a/weblate/api/tests.py b/weblate/api/tests.py
--- a/weblate/api/tests.py
+++ b/weblate/api/tests.py
@@ -1343,6 +1343,11 @@ def test_create_component_no_push(self):
             "weblate://test/test",
         )
         self.assertEqual(response.data["repo"], repo_url)
+        self.assertEqual(
+            response.data["linked_component"],
+            "http://example.com"
+            + reverse("api:component-detail", kwargs=self.component_kwargs),
+        )
 
     def test_create_component_empty_push(self):
         repo_url = self.format_local_path(self.git_repo_path)
@@ -1369,6 +1374,11 @@ def test_create_component_empty_push(self):
             "weblate://test/test",
         )
         self.assertEqual(response.data["repo"], repo_url)
+        self.assertEqual(
+            response.data["linked_component"],
+            "http://example.com"
+            + reverse("api:component-detail", kwargs=self.component_kwargs),
+        )
 
     def test_create_component_no_match(self):
         response = self.do_request(
Repository: pwr-Solaar/Solaar

Issue:
no battery status on M510 mouse



Discussion:
Register 0x0D is not valid for M510, however 0x07 appears to return a battery status.

Same behavious in Performance MX.

Register 07 also returns the battery status for the K800 keyboard. I have documented it at https://git.lekensteyn.nl/ltunify/tree/registers.txt:

```
Format: 10 DEVID 07   <battery level> <some magic> 00 00
(or: response to reading register, 10 DEVID 81 07   07 <batlvl> <magic> 00)
Battery level:
00 is not possible for battery level, when the keyboard went off because of zero
    power, 01 was still the reported value
01 - red zone
03 - one bar
05 - two bars
07 - three bars
Some magic:
00 - after unplugging/when not connected
25 - after plugging in USB power
```

Currently the return value is ignored. What about this mapping (I do not know the percentages, but the below seems the best we can get):

```
07 Full
05 Good
03 Low
01 Critical
```

I see there is a regular polling for register 07 within the GUI tool for the HID++ 1.0 keyboard device, can't the Battery notifications flag be used instead of plain polling? The logitech software definitely does not poll like this for batteries.


Resolving patch:
diff --git a/lib/logitech/unifying_receiver/hidpp10.py b/lib/logitech/unifying_receiver/hidpp10.py
--- a/lib/logitech/unifying_receiver/hidpp10.py
+++ b/lib/logitech/unifying_receiver/hidpp10.py
@@ -94,8 +94,16 @@ def get_battery(device):
 
 	reply = get_register(device, 'battery_status', 0x07)
 	if reply:
-		battery_status = ord(reply[:1])
-		_log.info("%s: battery status %02X", device, battery_status)
+		level = ord(reply[:1])
+		battery_status = ord(reply[2:3])
+		charge = (90 if level == 7 # full
+			else 50 if level == 5 # good
+			else 20 if level == 3 # low
+			else 5 if level == 1 # critical
+			else 0 ) # wtf?
+		status = ('charging' if battery_status == 0x25
+			else 'discharging')
+		return charge, status
 
 
 def get_serial(device):


Test patch:
Repository: pwr-Solaar/Solaar

Issue:
Please remove obnoxious popup window
If you want to inform the user that their battery is low changing the tray icon or sending a notification is sufficient.

Poping up a window  that takes focus on the users desktop is horribly annoying more so when it pops up repeatedly especially when it manages to do so in the middle of a game and ruin it.

I would appreciate if there was at least a way to disable this.



Discussion:
+1. The window is extremely annoying  :(

A notification via XDG Desktop Notifications would be perfect, IMHO.

+1

Perhaps one of the contributors comment on this issue? Having the option to disable notifications completely would be nice.


Resolving patch:
diff --git a/lib/solaar/ui/__init__.py b/lib/solaar/ui/__init__.py
--- a/lib/solaar/ui/__init__.py
+++ b/lib/solaar/ui/__init__.py
@@ -161,10 +161,10 @@ def _status_changed(device, alert, reason):
 	if alert & ALERT.ATTENTION:
 		tray.attention(reason)
 
-	need_popup = alert & (ALERT.SHOW_WINDOW | ALERT.ATTENTION)
+	need_popup = alert & ALERT.SHOW_WINDOW
 	window.update(device, need_popup)
 
-	if alert & ALERT.NOTIFICATION:
+	if alert & (ALERT.NOTIFICATION | ALERT.ATTENTION):
 		notify.show(device, reason)
 
 


Test patch:
Repository: pwr-Solaar/Solaar

Issue:
DPI and smart shift values are not stored in the config file (MX Master 2s)
I've set the DPI and the Smart Shift values but when you close solaar and then check `~/.config/solaar/config.json` the values are not written to the config file.

Version: 1.0.1
https://build.opensuse.org/request/show/719864 (I've updated the openSUSE package)


Discussion:

Resolving patch:
diff --git a/lib/logitech_receiver/settings.py b/lib/logitech_receiver/settings.py
--- a/lib/logitech_receiver/settings.py
+++ b/lib/logitech_receiver/settings.py
@@ -356,6 +356,8 @@ def prepare_write(self, new_value, current_value=None):
 		else:
 			if isinstance(new_value, int):
 				choice = self.choices[new_value]
+			elif int(new_value) in self.choices:
+				choice = self.choices[int(new_value)]
 			elif new_value in self.choices:
 				choice = self.choices[new_value]
 			else:


Test patch:
Repository: pwr-Solaar/Solaar

Issue:
solaar window always visible
**Information**

- Solaar version: 1.0.1 from github
- Distribution: github

The solaar window is always on top of my other windows.  This can become quite a pain, and is unnecessary because the window can be brought to the front by clicking on a receiver or device in the tray menu.


Discussion:

Resolving patch:
diff --git a/lib/solaar/ui/window.py b/lib/solaar/ui/window.py
--- a/lib/solaar/ui/window.py
+++ b/lib/solaar/ui/window.py
@@ -337,7 +337,6 @@ def _create():
 	# window.set_type_hint(Gdk.WindowTypeHint.UTILITY)
 	# window.set_skip_taskbar_hint(True)
 	# window.set_skip_pager_hint(True)
-	window.set_keep_above(True)
 	window.connect('delete-event', _hide)
 
 	vbox = _create_window_layout()


Test patch:
Repository: pwr-Solaar/Solaar

Issue:
upower no longer emits suspend and resume signals so Solaar doesn't respond correctly
This has been replaced by logind PrepareForSleep.

This is probably what is causing issue #686


Discussion:

Resolving patch:
diff --git a/lib/logitech_receiver/status.py b/lib/logitech_receiver/status.py
--- a/lib/logitech_receiver/status.py
+++ b/lib/logitech_receiver/status.py
@@ -223,7 +223,7 @@ def read_battery(self, timestamp=None):
 			# broadcasting it's battery status anyway, it will just take a little while.
 			# However, when the device has just been detected, it will not show
 			# any battery status for a while (broadcasts happen every 90 seconds).
-			if battery is None and _hidpp20.FEATURE.SOLAR_DASHBOARD in d.features:
+			if battery is None and d.features and _hidpp20.FEATURE.SOLAR_DASHBOARD in d.features:
 				d.feature_request(_hidpp20.FEATURE.SOLAR_DASHBOARD, 0x00, 1, 1)
 				return
 
@@ -261,7 +261,8 @@ def changed(self, active=None, alert=ALERT.NONE, reason=None, timestamp=None):
 
 					# Devices lose configuration when they are turned off,
 					# make sure they're up-to-date.
-					# _log.debug("%s settings %s", d, d.settings)
+					if _log.isEnabledFor(_DEBUG):
+						_log.debug("%s pushing device settings %s", d, d.settings)
 					for s in d.settings:
 						s.apply()
 
diff --git a/lib/solaar/upower.py b/lib/solaar/upower.py
--- a/lib/solaar/upower.py
+++ b/lib/solaar/upower.py
@@ -31,7 +31,7 @@
 def _suspend():
 	if _suspend_callback:
 		if _log.isEnabledFor(_INFO):
-			_log.info("received suspend event from UPower")
+			_log.info("received suspend event")
 		_suspend_callback()
 
 
@@ -39,9 +39,11 @@ def _suspend():
 def _resume():
 	if _resume_callback:
 		if _log.isEnabledFor(_INFO):
-			_log.info("received resume event from UPower")
+			_log.info("received resume event")
 		_resume_callback()
 
+def _suspend_or_resume(suspend):
+	_suspend() if suspend else _resume()
 
 def watch(on_resume_callback=None, on_suspend_callback=None):
 	"""Register callback for suspend/resume events.
@@ -56,6 +58,8 @@ def watch(on_resume_callback=None, on_suspend_callback=None):
 
 	_UPOWER_BUS = 'org.freedesktop.UPower'
 	_UPOWER_INTERFACE = 'org.freedesktop.UPower'
+	_LOGIND_BUS = 'org.freedesktop.login1.Manager'
+	_LOGIND_INTERFACE = 'org.freedesktop.login1'
 
 	# integration into the main GLib loop
 	from dbus.mainloop.glib import DBusGMainLoop
@@ -70,6 +74,9 @@ def watch(on_resume_callback=None, on_suspend_callback=None):
 	bus.add_signal_receiver(_resume, signal_name='Resuming',
 					dbus_interface=_UPOWER_INTERFACE, bus_name=_UPOWER_BUS)
 
+	bus.add_signal_receiver(_suspend_or_resume,'PrepareForSleep',
+					_LOGIND_BUS, _LOGIND_INTERFACE)
+
 	if _log.isEnabledFor(_INFO):
 		_log.info("connected to system dbus, watching for suspend/resume events")
 


Test patch:
Repository: pwr-Solaar/Solaar

Issue:
solaar does not show solaar.svg icon in tray when in started from the solaar bin directory
With current solaar from this repository

`cd bin; ./solaar`  ends up with no icon in the tray when solaar.svg should be shown
`bin/solaar` works correctly


Discussion:
What appears to be happening is that solaar is looking in the current directory for a file called solaar.  It finds that file and thinks that it contains the icon for solaar.  
I verified this hypothesis by renaming the solaar executable to solaarX and running as ./solaarX.  Sure enough, things work then.
But how to override this "feature" of GTK?
This appears to be https://bugs.launchpad.net/ubuntu/+source/libappindicator/+bug/1363277 which has been open for a long time.

Resolving patch:
diff --git a/lib/solaar/ui/tray.py b/lib/solaar/ui/tray.py
--- a/lib/solaar/ui/tray.py
+++ b/lib/solaar/ui/tray.py
@@ -155,17 +155,23 @@ def _scroll(tray_icon, event, direction=None):
 	if _log.isEnabledFor(_DEBUG):
 		_log.debug("using AppIndicator3")
 
+	# Defense against AppIndicator3 bug that treats files in current directory as icon files
+	# https://bugs.launchpad.net/ubuntu/+source/libappindicator/+bug/1363277
+	def _icon_file(icon_name):
+		icon_info = Gtk.IconTheme.get_default().lookup_icon(icon_name,_TRAY_ICON_SIZE,0)
+		return icon_info.get_filename() if icon_info else icon_name
+
 	def _create(menu):
 		theme_paths = Gtk.IconTheme.get_default().get_search_path()
 
 		ind = AppIndicator3.Indicator.new_with_path(
 						'indicator-solaar',
-						_icons.TRAY_INIT,
+						_icon_file(_icons.TRAY_INIT),
 						AppIndicator3.IndicatorCategory.HARDWARE,
 						':'.join(theme_paths))
 		ind.set_title(NAME)
 		ind.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
-		ind.set_attention_icon_full(_icons.TRAY_ATTENTION, '')
+		ind.set_attention_icon_full(_icon_file(_icons.TRAY_ATTENTION), '')
 		# ind.set_label(NAME, NAME)
 
 		ind.set_menu(menu)
@@ -194,7 +200,7 @@ def _update_tray_icon():
 			description = '\n'.join(tooltip_lines).rstrip('\n')
 
 		# icon_file = _icons.icon_file(icon_name, _TRAY_ICON_SIZE)
-		_icon.set_icon_full(tray_icon_name, description)
+		_icon.set_icon_full(_icon_file(tray_icon_name), description)
 
 
 	def _update_menu_icon(image_widget, icon_name):


Test patch:
Repository: pwr-Solaar/Solaar

Issue:
better identification of Solaar versions
`git describe` produces
0.9.2-339-g39791be
Instead it should produce something based on 1.0.1
`git describe --tags` produces
1.0.1-58-g39791be
which is much better.

I think that all that is required is to upgrade the 1.0.1 tag that already exists.


Discussion:
Is that maybe the difference between a lightweight tag and an annotated tag?

https://git-scm.com/docs/git-describe
https://git-scm.com/book/en/v2/Git-Basics-Tagging

I think so.  There is even a page on how to change a lightweight tag to an annotated one.
https://sartak.org/2011/01/replace-a-lightweight-git-tag-with-an-annotated-tag.html
@FFY00 is probably the right person to do this.
I can change the tags but we should change the command either way.

Resolving patch:
diff --git a/lib/solaar/__init__.py b/lib/solaar/__init__.py
--- a/lib/solaar/__init__.py
+++ b/lib/solaar/__init__.py
@@ -19,5 +19,5 @@
 
 from __future__ import absolute_import, division, print_function, unicode_literals
 
-__version__ = '1.0.1'
+__version__ = '1.0.2-rc1'
 NAME = 'Solaar'


Test patch:
Repository: pwr-Solaar/Solaar

Issue:
solaar does not show solaar.svg icon in tray when in started from the solaar bin directory
With current solaar from this repository

`cd bin; ./solaar`  ends up with no icon in the tray when solaar.svg should be shown
`bin/solaar` works correctly


Discussion:
What appears to be happening is that solaar is looking in the current directory for a file called solaar.  It finds that file and thinks that it contains the icon for solaar.  
I verified this hypothesis by renaming the solaar executable to solaarX and running as ./solaarX.  Sure enough, things work then.
But how to override this "feature" of GTK?
This appears to be https://bugs.launchpad.net/ubuntu/+source/libappindicator/+bug/1363277 which has been open for a long time.
My fix has a problem on high-resolution displays or in other cases where the icon size is large.  For some reason a file name is not rendered at the right resolution.
The solution is to check for the existence of the icon name in the current directory and only then use the file name for the icon instead of the simple icon name.

Resolving patch:
diff --git a/lib/solaar/ui/tray.py b/lib/solaar/ui/tray.py
--- a/lib/solaar/ui/tray.py
+++ b/lib/solaar/ui/tray.py
@@ -18,6 +18,7 @@
 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 from __future__ import absolute_import, division, print_function, unicode_literals
+import os
 
 from logging import getLogger, DEBUG as _DEBUG
 _log = getLogger(__name__)
@@ -158,6 +159,8 @@ def _scroll(tray_icon, event, direction=None):
 	# Defense against AppIndicator3 bug that treats files in current directory as icon files
 	# https://bugs.launchpad.net/ubuntu/+source/libappindicator/+bug/1363277
 	def _icon_file(icon_name):
+		if not os.path.isfile(icon_name):
+			return icon_name
 		icon_info = Gtk.IconTheme.get_default().lookup_icon(icon_name,_TRAY_ICON_SIZE,0)
 		return icon_info.get_filename() if icon_info else icon_name
 


Test patch:
Repository: pwr-Solaar/Solaar

Issue:
Backtrace when run without gtk installed
If you try to bring up the graphical interface without gtk installed, you get a backtrace:
```
Traceback (most recent call last):
  File "/usr/bin/solaar", line 57, in <module>
    solaar.gtk.main()
  File "/usr/lib/python3.7/site-packages/solaar/gtk.py", line 90, in main
    gi.require_version('Gtk', '3.0')
  File "/usr/lib64/python3.7/site-packages/gi/__init__.py", line 127, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gtk not available
```
It does appear that there is code to handle missing modules, but gtk doesn't get imported directly so it wouldn't trigger.  Maybe something like this?
```
diff --git a/lib/solaar/gtk.py b/lib/solaar/gtk.py
index f728420..20683af 100644
--- a/lib/solaar/gtk.py
+++ b/lib/solaar/gtk.py
@@ -87,8 +87,11 @@ def main():
        if not args: return
        if args.action: return _cli.run(args.action, args.hidraw_path)

-       gi = _require('gi', 'python-gi')
-       gi.require_version('Gtk', '3.0')
+       try:
+               gi.require_version('Gtk', '3.0')
+       except ValueError:
+               import sys
+               sys.exit("%s: Gtk (version 3) must be installed in order to run the graphical interface." % (NAME))
        _require('gi.repository.Gtk', 'gir1.2-gtk-3.0')

        try:
```
Can send a PR if desired, but I don't know if that's the right approach.


Discussion:
Obviously that patch deletes one line too many.
Yes, there is a problem in the code that tries to be helpful about missing packages.  The best way to solve it, I think, is to add functionality to the _require function.

Resolving patch:
diff --git a/lib/solaar/gtk.py b/lib/solaar/gtk.py
--- a/lib/solaar/gtk.py
+++ b/lib/solaar/gtk.py
@@ -31,10 +31,12 @@
 #
 #
 
-def _require(module, os_package):
+def _require(module, os_package, gi=None, gi_package=None, gi_version=None):
 	try:
+		if gi is not None:
+			gi.require_version(gi_package,gi_version)
 		return importlib.import_module(module)
-	except ImportError:
+	except (ImportError, ValueError):
 		import sys
 		sys.exit("%s: missing required system package %s" % (NAME, os_package))
 
@@ -94,8 +96,7 @@ def main():
 		return _cli.run(args.action, args.hidraw_path)
 
 	gi = _require('gi', 'python3-gi or python3-gobject')
-	gi.require_version('Gtk', '3.0')
-	_require('gi.repository.Gtk', 'gir1.2-gtk-3.0')
+	_require('gi.repository.Gtk', 'gir1.2-gtk-3.0', gi, 'Gtk', '3.0')
 
 	try:
 		import solaar.ui as ui


Test patch:
Repository: pwr-Solaar/Solaar

Issue:
authorship of Solaar in setup.py
Daniel Pavel is listed as the sole author of Solaar in setup.py 

As far as I can tell, this puts him and his email in several repositories, such as PyPI https://pypi.org/project/solaar/

Who should be put there?


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -8,28 +8,10 @@
 
 autostart_path = '/etc/xdg/autostart'
 
-import sys
-backup_path_0 = sys.path[0]
-sys.path[0] = backup_path_0 + '/lib'
 #from solaar import NAME, __version__
 __version__ = '1.0.2-rc1'
 NAME = 'Solaar'
 
-sys.path[0] = backup_path_0
-
-if 'install' in sys.argv:
-	# naively guess where the autostart .desktop file should be installed
-	if '--prefix' in sys.argv or any(x.startswith('--prefix=') for x in sys.argv) or '--home' in sys.argv:
-		autostart_path = 'etc/xdg/autostart'
-	elif '--user' in sys.argv:
-		from os import environ
-		from os import path
-		xdg_config_home = environ.get('XDG_CONFIG_HOME', path.expanduser(path.join('~', '.config')))
-		autostart_path = path.join(xdg_config_home, 'autostart')
-		del environ, path, xdg_config_home
-
-del sys, backup_path_0
-
 
 def _data_files():
 	from os.path import dirname as _dirname
@@ -43,6 +25,7 @@ def _data_files():
 
 	yield 'share/applications', ['share/applications/solaar.desktop']
 	yield autostart_path, ['share/autostart/solaar.desktop']
+	yield '/etc/udev/rules.d', ['rules.d/42-logitech-unify-permissions.rules']
 
 	del _dirname
 
@@ -56,7 +39,6 @@ def _data_files():
 battery status.
 '''.strip(),
 		author='Daniel Pavel',
-		author_email='daniel.pavel@gmail.com',
 		license='GPLv2',
 		url='http://pwr-solaar.github.io/Solaar/',
 		classifiers=[


Test patch: