Display transliterated filename in GUI

This commit is contained in:
brunoherbelin
2021-01-01 20:41:39 +01:00
parent 11690dfb8c
commit f8e926040a
5 changed files with 24 additions and 10 deletions

View File

@@ -56,6 +56,16 @@ string GstToolkit::time_to_string(guint64 t, time_string_mode m)
}
std::string GstToolkit::filename_to_uri(std::string path)
{
// set uri to open
gchar *uritmp = gst_filename_to_uri(path.c_str(), NULL);
std::string uri( uritmp );
g_free(uritmp);
return uri;
}
list<string> GstToolkit::all_plugins()
{
list<string> pluginlist;

View File

@@ -16,6 +16,7 @@ typedef enum {
} time_string_mode;
std::string time_to_string(guint64 t, time_string_mode m = TIME_STRING_ADJUSTED);
std::string filename_to_uri(std::string filename);
std::string gst_version();

View File

@@ -32,7 +32,9 @@ std::map <ImGuiToolkit::font_style, ImFont*>fontmap;
void ImGuiToolkit::ButtonOpenUrl( const char* url, const ImVec2& size_arg )
{
char label[512];
sprintf( label, "%s %s", ICON_FA_EXTERNAL_LINK_ALT, url );
std::string str = SystemToolkit::transliterate( url );
sprintf( label, "%s %s", ICON_FA_EXTERNAL_LINK_ALT, str.c_str() );
if ( ImGui::Button(label, size_arg) )
SystemToolkit::open(url);

View File

@@ -13,6 +13,7 @@ using namespace std;
#include "Visitor.h"
#include "SystemToolkit.h"
#include "GlmToolkit.h"
#include "GstToolkit.h"
#include "MediaPlayer.h"
@@ -186,12 +187,10 @@ static MediaInfo UriDiscoverer_(std::string uri)
void MediaPlayer::open(string path)
{
// set path
filename_ = path;
filename_ = SystemToolkit::transliterate( path );
// set uri to open
gchar *uritmp = gst_filename_to_uri(path.c_str(), NULL);
uri_ = string( uritmp );
g_free(uritmp);
uri_ = GstToolkit::filename_to_uri(path);
// reset
ready_ = false;

View File

@@ -15,7 +15,7 @@ using namespace std;
#include "imgui_impl_opengl3.h"
// Desktop OpenGL function loader
#include <glad/glad.h>
#include <glad/glad.h>
// Include glfw3.h after our OpenGL definitions
#include <GLFW/glfw3.h>
@@ -1003,7 +1003,7 @@ void ToolBox::Render()
// About and other utility windows
if (show_icons_window)
ImGuiToolkit::ShowIconsWindow(&show_icons_window);
ImGuiToolkit::ShowIconsWindow(&show_icons_window);
if (show_sandbox)
ShowSandbox(&show_sandbox);
if (show_demo_window)
@@ -2139,7 +2139,7 @@ void Navigator::RenderSourcePannel(Source *s)
// ImGui::EndPopup();
// }
}
ImGui::End();
ImGui::End();
}
@@ -2263,7 +2263,8 @@ void Navigator::RenderNewPannel()
fileImportFileDialogs.pop_back();
fileDialogPending_ = false;
// create a source with this file
std::string label = open_filename.substr( open_filename.size() - MIN( 35, open_filename.size()) );
std::string label = SystemToolkit::transliterate( open_filename );
label = label.substr( label.size() - MIN( 35, label.size()) );
new_source_preview_.setSource( Mixer::manager().createSourceFile(open_filename), label);
}
}
@@ -2277,7 +2278,8 @@ void Navigator::RenderNewPannel()
{
std::string recentpath(*path);
if ( SystemToolkit::file_exists(recentpath)) {
std::string label = SystemToolkit::trunc_filename(recentpath, 35);
std::string label = SystemToolkit::transliterate( recentpath );
label = SystemToolkit::trunc_filename(label, 35);
if (ImGui::Selectable( label.c_str() )) {
new_source_preview_.setSource( Mixer::manager().createSourceFile(recentpath.c_str()), label);
}