Skip to content

Commit

Permalink
🔀 Merge pull request #38 from ChildishGiant/file-chooser-native
Browse files Browse the repository at this point in the history
  • Loading branch information
sergius02 authored Dec 20, 2021
2 parents 11e62e7 + 22bacba commit f3f2a5f
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 97 deletions.
3 changes: 1 addition & 2 deletions com.github.sergius02.qrit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ finish-args:
- '--share=ipc'
- '--socket=fallback-x11'
- '--socket=wayland'
- '--filesystem=home'
# TODO: uncomment this when adding dark style support
# - '--system-talk-name=org.freedesktop.Accounts'

Expand All @@ -20,7 +19,7 @@ modules:
sources:
- type: archive
url: https://fukuchi.org/works/qrencode/qrencode-4.1.1.tar.gz
sha512: 209bb656ae3f391b03c7b3ceb03e34f7320b0105babf48b619e7a299528b8828449e0e7696f0b5db0d99170a81709d0518e34835229a748701e7df784e58a9ce
sha512: 209bb656ae3f391b03c7b3ceb03e34f7320b0105babf48b619e7a299528b8828449e0e7696f0b5db0d99170a81709d0518e34835229a748701e7df784e58a9ce

- name: qrit
buildsystem: meson
Expand Down
5 changes: 2 additions & 3 deletions resources/com.github.sergius02.qrit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
<gresource prefix="/com/github/sergius02/qrit/">
<file>ui/qrit.ui</file>
<file>ui/headerbar.ui</file>
<file>ui/file_chooser.ui</file>


<file>icons/icon_clipboard.svg</file>
<file>icons/icon_github.svg</file>
<file>icons/icon_play.svg</file>
Expand All @@ -13,4 +12,4 @@
<file>icons/icon_qr.svg</file>
<file>icons/icon_qr18.svg</file>
</gresource>
</gresources>
</gresources>
56 changes: 0 additions & 56 deletions resources/ui/file_chooser.ui

This file was deleted.

4 changes: 2 additions & 2 deletions src/QRitUtils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class QRit.QRitUtils {
QRit.QRitUtils.file_extension = application.window.combobox_formats.get_active_text ();
string background_hex = QRit.QRitUtils.to_hex (application.window.background);
string foregroun_hex = QRit.QRitUtils.to_hex (application.window.foreground);

string cached_file = application.cache_folder + "/Awesome_QR." + file_extension;
string[] command = {
"qrencode", // Base command
Expand All @@ -39,7 +39,7 @@ public class QRit.QRitUtils {
}
}

/**
/**
* Save the QR to the $HOME folder
*/
public static void save_qr (QRit.Application application) {
Expand Down
3 changes: 1 addition & 2 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
sources = files (
'Application.vala',
'QRitUtils.vala',

'widgets/Window.vala',
'widgets/HeaderBar.vala',
'widgets/FileChooser.vala'
)
29 changes: 0 additions & 29 deletions src/widgets/FileChooser.vala

This file was deleted.

30 changes: 27 additions & 3 deletions src/widgets/HeaderBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,33 @@ public class QRit.HeaderBar : Gtk.HeaderBar {
});

this.button_openfile.clicked.connect (() => {
QRit.FileChooser file_chooser = new QRit.FileChooser (application);
file_chooser.transient_for = application.window;
file_chooser.present ();

var file_chooser = new Gtk.FileChooserNative (
null,
application.window,
Gtk.FileChooserAction.OPEN,
_("Open"),
_("Cancel")
);

Gtk.FileFilter file_filter = new Gtk.FileFilter ();
file_filter.add_pattern ("*.txt");
file_filter.add_pattern ("*.html");
file_filter.add_pattern ("*.css");
file_filter.add_pattern ("*.js");
file_chooser.add_filter (file_filter);

file_chooser.response.connect ((id) => {
if (id == Gtk.ResponseType.ACCEPT) {
string file_content = QRitUtils.read_file (file_chooser.get_filename ());
file_chooser.dispose ();
QRitUtils.generate_qr (application, file_content);
} else {
file_chooser.dispose ();
}
});

file_chooser.show ();
});

this.button_contenttoqr.sensitive = false;
Expand Down

0 comments on commit f3f2a5f

Please sign in to comment.