-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
159 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# Copyright © 2020, Nguyễn Hồng Quân <[email protected]> | ||
|
||
import os | ||
import io | ||
from gettext import gettext as _ | ||
from urllib.parse import urlsplit | ||
|
@@ -9,7 +8,6 @@ | |
|
||
import gi | ||
import zbar | ||
import logbook | ||
from logbook import Logger | ||
from PIL import Image | ||
|
||
|
@@ -28,7 +26,7 @@ | |
|
||
from gi.repository import GObject, GLib, Gtk, Gdk, Gio, GdkPixbuf, Handy, Rsvg, Gst, GstApp, NM | ||
|
||
from .consts import APP_ID, SHORT_NAME | ||
from .consts import APP_ID | ||
from . import __version__ | ||
from . import ui | ||
from .resources import get_ui_filepath, guess_content_type, cache_http_file | ||
|
@@ -51,6 +49,7 @@ class CoBangApplication(Gtk.Application): | |
STACK_CHILD_NAME_WEBCAM = 'src_webcam' | ||
STACK_CHILD_NAME_IMAGE = 'src_image' | ||
GST_SOURCE_NAME = 'webcam_source' | ||
GST_FLIP_FILTER_NAME = 'videoflip' | ||
SIGNAL_QRCODE_DETECTED = 'qrcode-detected' | ||
window: Optional[Gtk.Window] = None | ||
main_grid: Optional[Gtk.Grid] = None | ||
|
@@ -67,6 +66,7 @@ class CoBangApplication(Gtk.Application): | |
raw_result_buffer: Optional[Gtk.TextBuffer] = None | ||
webcam_combobox: Optional[Gtk.ComboBox] = None | ||
webcam_store: Optional[Gtk.ListStore] = None | ||
btn_mirror: Optional[Gtk.ToggleButton] = None | ||
frame_image: Optional[Gtk.AspectFrame] = None | ||
# Box holds the emplement to display when no image is chosen | ||
box_image_empty: Optional[Gtk.Box] = None | ||
|
@@ -117,7 +117,8 @@ def setup_actions(self): | |
def build_gstreamer_pipeline(self, src_type: str = 'v4l2src'): | ||
# https://gstreamer.freedesktop.org/documentation/application-development/advanced/pipeline-manipulation.html?gi-language=c#grabbing-data-with-appsink | ||
# Try GL backend first | ||
command = (f'{src_type} name={self.GST_SOURCE_NAME} ! videoconvert ! tee name=t ! ' | ||
video_flip_method = 'horizontal-flip' if (self.btn_mirror and self.btn_mirror.get_active()) else 'none' | ||
command = (f'{src_type} name={self.GST_SOURCE_NAME} ! videoflip name={self.GST_FLIP_FILTER_NAME} method={video_flip_method} ! videoconvert ! tee name=t ! ' | ||
# FIXME: The produced video screen is wider than expected, with redundant black padding | ||
f'queue ! videoscale ! ' | ||
f'glsinkbin sink="gtkglsink name={self.SINK_NAME}" name=sink_bin ' | ||
|
@@ -132,7 +133,7 @@ def build_gstreamer_pipeline(self, src_type: str = 'v4l2src'): | |
if not pipeline: | ||
logger.info('OpenGL is not available, fallback to normal GtkSink') | ||
# Fallback to non-GL | ||
command = (f'{src_type} name={self.GST_SOURCE_NAME} ! videoconvert ! tee name=t ! ' | ||
command = (f'{src_type} name={self.GST_SOURCE_NAME} ! videoflip name={self.GST_FLIP_FILTER_NAME} method={video_flip_method} ! videoconvert ! tee name=t ! ' | ||
f'queue ! videoscale ! gtksink name={self.SINK_NAME} ' | ||
't. ! queue leaky=1 max-size-buffers=2 ! video/x-raw,format=GRAY8 ! ' | ||
f'appsink name={self.APPSINK_NAME}') | ||
|
@@ -167,6 +168,7 @@ def build_main_window(self): | |
self.raw_result_expander = builder.get_object('raw-result-expander') | ||
self.webcam_store = builder.get_object('webcam-list') | ||
self.webcam_combobox = builder.get_object('webcam-combobox') | ||
self.btn_mirror = builder.get_object('btn-mirror') | ||
self.frame_image = builder.get_object('frame-image') | ||
self.box_image_empty = builder.get_object('box-image-empty') | ||
main_menubutton: Gtk.MenuButton = builder.get_object('main-menubutton') | ||
|
@@ -198,6 +200,7 @@ def signal_handlers_for_glade(self): | |
'on_evbox_playpause_leave_notify_event': self.on_evbox_playpause_leave_notify_event, | ||
'on_info_bar_response': self.on_info_bar_response, | ||
'on_btn_copy_clicked': self.on_btn_copy_clicked, | ||
'on_btn-mirror_toggled': self.on_btn_mirror_toggled, | ||
} | ||
|
||
def discover_webcam(self): | ||
|
@@ -642,6 +645,16 @@ def on_btn_copy_clicked(self, button: Gtk.Button): | |
button.set_tooltip_text(_('Copied')) | ||
GLib.timeout_add_seconds(3, remove_tooltip, button) | ||
|
||
def on_btn_mirror_toggled(self, button: Gtk.ToggleButton): | ||
if not self.gst_pipeline: | ||
return | ||
ppl_source = self.gst_pipeline.get_by_name(self.GST_SOURCE_NAME) | ||
ppl_source.set_state(Gst.State.NULL) | ||
self.gst_pipeline.set_state(Gst.State.NULL) | ||
mirror = button.get_active() | ||
self.gst_pipeline.get_by_name(self.GST_FLIP_FILTER_NAME).set_property('method', 'horizontal-flip' if mirror else 'none') | ||
self.gst_pipeline.set_state(Gst.State.PLAYING) | ||
|
||
def on_info_bar_response(self, infobar: Gtk.InfoBar, response_id: int): | ||
infobar.set_visible(False) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PROJECT VERSION\n" | ||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" | ||
"POT-Creation-Date: 2024-03-27 10:09+0700\n" | ||
"POT-Creation-Date: 2024-06-15 17:22+0700\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -17,16 +17,16 @@ msgstr "" | |
"Content-Transfer-Encoding: 8bit\n" | ||
"Generated-By: Babel 2.10.3\n" | ||
|
||
#: cobang/app.py:99 | ||
#: cobang/app.py:100 | ||
msgid "CoBang: QR scanner for Linux" | ||
msgstr "" | ||
|
||
#: cobang/app.py:547 | ||
#: cobang/app.py:544 | ||
#, python-format | ||
msgid "Unsupported file type %s!" | ||
msgstr "" | ||
|
||
#: cobang/app.py:648 | ||
#: cobang/app.py:645 | ||
msgid "Copied" | ||
msgstr "" | ||
|
||
|
@@ -86,20 +86,24 @@ msgstr "" | |
msgid "Image" | ||
msgstr "" | ||
|
||
#: data/cobang-resp.glade:424 | ||
#: data/cobang-resp.glade:419 | ||
msgid "Mirror" | ||
msgstr "Gương" | ||
|
||
#: data/cobang-resp.glade:439 | ||
msgid "Please choose an image file" | ||
msgstr "" | ||
|
||
#: data/cobang-resp.glade:472 | ||
#: data/cobang-resp.glade:487 | ||
msgid "Result" | ||
msgstr "" | ||
|
||
#: data/cobang-resp.glade:512 | ||
#: data/cobang-resp.glade:527 | ||
msgid "Raw result" | ||
msgstr "" | ||
|
||
#: data/url-display.glade:16 | ||
msgid "Found an URL. Click to open:" | ||
msgid "Found a URL. Click to open:" | ||
msgstr "" | ||
|
||
#: data/url-display.glade:26 | ||
|
@@ -145,4 +149,3 @@ msgstr "" | |
#: data/wifi-display.glade:101 | ||
msgid "Save" | ||
msgstr "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PROJECT VERSION\n" | ||
"Report-Msgid-Bugs-To: [email protected]\n" | ||
"POT-Creation-Date: 2024-03-27 10:09+0700\n" | ||
"POT-Creation-Date: 2024-06-15 17:22+0700\n" | ||
"PO-Revision-Date: 2023-04-14 19:26+0200\n" | ||
"Last-Translator: Miquel Lionel <[email protected]>\n" | ||
"Language: fr\n" | ||
|
@@ -16,19 +16,19 @@ msgstr "" | |
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=utf-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Generated-By: Babel 2.14.0\n" | ||
"Generated-By: Babel 2.10.3\n" | ||
|
||
#: cobang/app.py:99 | ||
#: cobang/app.py:100 | ||
#, fuzzy | ||
msgid "CoBang: QR scanner for Linux" | ||
msgstr "Scanneur de code QR pour Linux" | ||
|
||
#: cobang/app.py:547 | ||
#: cobang/app.py:544 | ||
#, python-format | ||
msgid "Unsupported file type %s!" | ||
msgstr "Type de fichier %s non supporté!" | ||
|
||
#: cobang/app.py:648 | ||
#: cobang/app.py:645 | ||
msgid "Copied" | ||
msgstr "Copié" | ||
|
||
|
@@ -96,20 +96,25 @@ msgstr "" | |
msgid "Image" | ||
msgstr "Image" | ||
|
||
#: data/cobang-resp.glade:424 | ||
#: data/cobang-resp.glade:419 | ||
msgid "Mirror" | ||
msgstr "Gương" | ||
|
||
#: data/cobang-resp.glade:439 | ||
msgid "Please choose an image file" | ||
msgstr "Veuillez choisir un fichier image" | ||
|
||
#: data/cobang-resp.glade:472 | ||
#: data/cobang-resp.glade:487 | ||
msgid "Result" | ||
msgstr "Résultat" | ||
|
||
#: data/cobang-resp.glade:512 | ||
#: data/cobang-resp.glade:527 | ||
msgid "Raw result" | ||
msgstr "Résultat brut" | ||
|
||
#: data/url-display.glade:16 | ||
msgid "Found an URL. Click to open:" | ||
#, fuzzy | ||
msgid "Found a URL. Click to open:" | ||
msgstr "URL trouvée. Cliquez pour ouvrir:" | ||
|
||
#: data/url-display.glade:26 | ||
|
Oops, something went wrong.