Commit 722d975f authored by Andoni Morales's avatar Andoni Morales Committed by Luis de Bethencourt

Make snappy relocatable

Signed-off-by: Luis de Bethencourt's avatarLuis de Bethencourt <luis@debethencourt.com>
parent 5a8a854c
......@@ -166,11 +166,38 @@ main (int argc, char *argv[])
gchar *version_str;
GList *uri_list;
GOptionContext *context;
gchar *data_dir;
#ifdef ENABLE_DBUS
SnappyMP *mp_obj = NULL;
#endif
/* Try to find the path for our resources in case snappy was relocated */
data_dir = g_strdup(SNAPPY_DATA_DIR);
if (!g_file_test(data_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
gchar *root_dir;
#ifdef G_OS_WIN32
root_dir = g_win32_get_package_installation_directory_of_module(NULL);
#elif !defined(G_OS_UNIX)
gchar *exec_path;
gchar *bin_dir;
exec_path = g_file_read_link("/proc/self/exe", NULL);
bin_dir = g_path_get_dirname(exec_path);
root_dir = g_build_filename(bin_dir, "..", NULL);
g_free(exec_path);
g_free(bin_dir);
#else
root_dir = NULL;
#endif
if (root_dir != NULL) {
data_dir = g_build_filename(root_dir, "share", "snappy", NULL);
g_free(root_dir);
}
}
if (!g_thread_supported ())
g_thread_init (NULL);
......@@ -189,6 +216,7 @@ main (int argc, char *argv[])
ui->fullscreen = fullscreen;
ui->hide = hide;
ui->tags = tags;
ui->data_dir = data_dir;
interface_init (ui);
video_texture = clutter_texture_new ();
......
......@@ -402,20 +402,20 @@ load_controls (UserInterface * ui)
ClutterActor *vol_int_box = NULL;
GError *error = NULL;
vid_panel_png = g_build_filename (SNAPPY_DATA_DIR, "vid-panel.png", NULL);
ui->play_png = g_build_filename (SNAPPY_DATA_DIR, "media-actions-start.png",
vid_panel_png = g_build_filename (ui->data_dir, "vid-panel.png", NULL);
ui->play_png = g_build_filename (ui->data_dir, "media-actions-start.png",
NULL);
ui->pause_png = g_build_filename (SNAPPY_DATA_DIR, "media-actions-pause.png",
ui->pause_png = g_build_filename (ui->data_dir, "media-actions-pause.png",
NULL);
ui->volume_low_png = g_build_filename (SNAPPY_DATA_DIR,
ui->volume_low_png = g_build_filename (ui->data_dir,
"audio-volume-low.png", NULL);
ui->volume_high_png = g_build_filename (SNAPPY_DATA_DIR,
ui->volume_high_png = g_build_filename (ui->data_dir,
"audio-volume-high.png", NULL);
ui->subtitle_toggle_png = g_build_filename (SNAPPY_DATA_DIR,
ui->subtitle_toggle_png = g_build_filename (ui->data_dir,
"subtitle-toggle.png", NULL);
ui->video_stream_toggle_png = g_build_filename (SNAPPY_DATA_DIR,
ui->video_stream_toggle_png = g_build_filename (ui->data_dir,
"video-stream-toggle.png", NULL);
ui->audio_stream_toggle_png = g_build_filename (SNAPPY_DATA_DIR,
ui->audio_stream_toggle_png = g_build_filename (ui->data_dir,
"audio-stream-toggle.png", NULL);
icon_files[0] = vid_panel_png;
......
......@@ -91,6 +91,7 @@ struct _UserInterface
gchar *volume_low_png, *volume_high_png;
gchar *subtitle_toggle_png;
gchar *video_stream_toggle_png, *audio_stream_toggle_png;
gchar *data_dir;
gchar *duration_str;
GList *uri_list;
......
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