Commit fc00e571 authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Use a Gtk.LinkButton to browse the games directory

This is way simpler, and it does not require certain programs to be
installed and started.  All the work is offloaded to Gtk+.
parent 24273062
Pipeline #164151 passed with stages
in 44 minutes and 56 seconds
......@@ -41,7 +41,6 @@ mingw64-configure \
--enable-runtime-prefix='TAROT_PREFIX' \
USER_DATA_DIR_VARIABLE='LOCALAPPDATA' \
--with-static-program-name=yes \
--with-file-manager-program=explorer.exe \
HOST_SYSROOT="/usr/x86_64-w64-mingw32/sys-root/mingw" \
|| exit 1
make -j 8 nsi || exit 1
......
......@@ -22,9 +22,6 @@ AC_SUBST([VERSION_ADDITIONAL], m4_esyscmd([./get-version.sh package | tail -c +$
AC_SUBST([LIBTOOL_CURRENT], m4_esyscmd([./get-version.sh libtool | cut -d ':' -f 1]))
AC_SUBST([LIBTOOL_REVISION], m4_esyscmd([./get-version.sh libtool | cut -d ':' -f 2]))
AC_SUBST([LIBTOOL_AGE], m4_esyscmd([./get-version.sh libtool | cut -d ':' -f 3]))
AC_ARG_WITH([file-manager-program], AS_HELP_STRING([--with-file-manager-program=PROGRAM],
[The program to call to open the games directory, instead of calling the org.freedesktop.FileManager1 DBus interface.]))
AC_DEFINE_UNQUOTED([EXTERNAL_FILE_MANAGER_PROGRAM], "$with_file_manager_program", [The name of the program to call to open a specific directory in an external file manager. If set to 'no' or empty, then use the the org.freedesktop.FileManager1 DBus interface.])
# Checks for programs.
AC_PROG_CC
......
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tarot 0.4.2.83-ebdc-dirty\n"
"Report-Msgid-Bugs-To: vivien@planete-kraus.eu\n"
"POT-Creation-Date: 2019-09-05 23:17+0200\n"
"POT-Creation-Date: 2019-09-06 22:21+0200\n"
"PO-Revision-Date: 2019-09-05 23:18+0200\n"
"Last-Translator: Vivien Kraus <vivien@planete-kraus.eu>\n"
"Language-Team: French\n"
......@@ -543,7 +543,7 @@ msgstr ""
"Erreur : l'en-tête ARFF installé (%s/features-header.txt) n'est pas "
"compatible avec cette version (%s).\n"
#: src/tarot-app/gui/window.vala:154
#: src/tarot-app/gui/window.vala:157
msgid ""
"If you find that the AI is too weak, send me your game files at "
"vivien@planete-kraus.eu :)"
......@@ -551,30 +551,20 @@ msgstr ""
"Si vous trouvez que l'IA est trop faible, envoyez-moi vos fichiers de partie "
"à vivien@planete-kraus.eu :)"
#: src/tarot-app/gui/window.vala:155
#: src/tarot-app/gui/window.vala:158
msgid "Copyright © 2019 Vivien Kraus"
msgstr "Copyright © 2019 Vivien Kraus"
#: src/tarot-app/gui/window.vala:255
#: src/tarot-app/gui/window.vala:252
#, c-format
msgid "Error: could not log the game: %s\n"
msgstr "Erreur : impossible d'enregistrer la partie : %s\n"
#: src/tarot-app/gui/window.vala:317
#: src/tarot-app/gui/window.vala:314
#, c-format
msgid "Error: could not set up the game: %s\n"
msgstr "Erreur : impossible de mettre en place la partie : %s\n"
#: src/tarot-app/gui/window.vala:407
#, c-format
msgid "Could not run %s!\n"
msgstr "Impossible d'exécuter %s !\n"
#: src/tarot-app/gui/window.vala:416
#, c-format
msgid "Could not run the file manager: %s\n"
msgstr "Impossible d'exécuter le gestionnaire de fichiers : %s\n"
#: src/tarot-app/gui/widget.vala:309
#, c-format
msgid ""
......@@ -1657,6 +1647,12 @@ msgstr "Écart"
msgid "Call: [card]"
msgstr "Appel : [carte]"
#~ msgid "Could not run %s!\n"
#~ msgstr "Impossible d'exécuter %s !\n"
#~ msgid "Could not run the file manager: %s\n"
#~ msgstr "Impossible d'exécuter le gestionnaire de fichiers : %s\n"
#~ msgid "2017, 2018, 2019"
#~ msgstr "2017, 2018, 2019"
......
......@@ -256,7 +256,7 @@ Author: Vivien Kraus
</packing>
</child>
<child>
<object class="GtkButton" id="button_open">
<object class="GtkLinkButton" id="button_browse_games">
<property name="label" translatable="yes">Game files</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
......@@ -264,7 +264,6 @@ Author: Vivien Kraus
<property name="image">image2</property>
<property name="relief">none</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="open_game_files" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
......@@ -275,6 +274,7 @@ Author: Vivien Kraus
</object>
<packing>
<property name="submenu">main</property>
<property name="position">1</property>
</packing>
</child>
</object>
......
......@@ -121,6 +121,9 @@ namespace Tarot {
[GtkChild]
private Gtk.PopoverMenu menu_popover;
[GtkChild]
private Gtk.LinkButton button_browse_games;
[GtkCallback]
private void show_new_game_page () {
my_game = new Tarot.Game.alloc ();
......@@ -172,12 +175,6 @@ namespace Tarot {
menu_popover.hide ();
}
[GtkCallback]
private void open_game_files () {
browse_games_dir ();
menu_popover.hide ();
}
[GtkCallback]
private void show_menu_popover () {
menu_popover.show_all ();
......@@ -395,29 +392,6 @@ namespace Tarot {
tarot_widget.dont_ask ();
}
private void browse_games_dir () {
var location = GLib.Environment.get_variable ("SAVEDGAMESDIR");
if (EXTERNAL_FILE_MANAGER_PROGRAM != ""
&& EXTERNAL_FILE_MANAGER_PROGRAM != "no") {
string[] args = { EXTERNAL_FILE_MANAGER_PROGRAM, location, null };
GLib.Pid pid;
try {
GLib.Process.spawn_async (null, args, null, GLib.SpawnFlags.SEARCH_PATH, null, out pid);
} catch (GLib.SpawnError e) {
stderr.printf (_ ("Could not run %s!\n"), EXTERNAL_FILE_MANAGER_PROGRAM);
}
} else {
FileManagerInterface fm;
try {
fm = Bus.get_proxy_sync (BusType.SESSION, "org.freedesktop.FileManager1", "/org/freedesktop/FileManager1");
string[] paths = { "file://" + location };
fm.ShowFolders (paths, "eu.planete_kraus.Tarot");
} catch (GLib.Error e) {
stderr.printf (_ ("Could not run the file manager: %s\n"), e.message);
}
}
}
private GLib.Rand prng = new GLib.Rand ();
public Window (Gtk.Application app) {
......@@ -426,6 +400,7 @@ namespace Tarot {
var provider = new Gtk.CssProvider ();
provider.load_from_resource ("/eu/planete_kraus/Tarot/style.css");
Gtk.StyleContext.add_provider_for_screen (screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
button_browse_games.uri = "file://" + GLib.Environment.get_variable ("SAVEDGAMESDIR");
show_new_game_page ();
}
}
......
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