| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#include <gtk/gtk.h> |
| 5 |
|
| 6 |
#include "alsa.h" |
| 7 |
#include "iface-waiting.h" |
| 8 |
#include "scarlett2-ioctls.h" |
| 9 |
#include "window-iface.h" |
| 10 |
|
| 11 |
|
| 12 |
struct timeout_data { |
| 13 |
GtkWidget *box; |
| 14 |
GtkWidget *spinner; |
| 15 |
GtkWidget *message_label; |
| 16 |
guint timeout_id; |
| 17 |
}; |
| 18 |
|
| 19 |
|
| 20 |
static gboolean on_timeout(gpointer user_data) { |
| 21 |
struct timeout_data *data = (struct timeout_data *)user_data; |
| 22 |
|
| 23 |
|
| 24 |
gtk_box_remove(GTK_BOX(data->box), data->spinner); |
| 25 |
|
| 26 |
|
| 27 |
if (data->message_label && GTK_IS_WIDGET(data->message_label)) |
| 28 |
gtk_label_set_markup( |
| 29 |
GTK_LABEL(data->message_label), |
| 30 |
"Driver not detected. Please ensure " |
| 31 |
"<span font='monospace'>fcp-server</span> from " |
| 32 |
"<a href=\"https://github.com/geoffreybennett/fcp-support\">" |
| 33 |
"https://github.com/geoffreybennett/fcp-support</a> " |
| 34 |
"has been installed." |
| 35 |
); |
| 36 |
|
| 37 |
|
| 38 |
data->timeout_id = 0; |
| 39 |
|
| 40 |
|
| 41 |
return FALSE; |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
static void on_widget_dispose(gpointer data, GObject *where_the_object_was) { |
| 46 |
struct timeout_data *timeout_data = (struct timeout_data *)data; |
| 47 |
|
| 48 |
|
| 49 |
if (timeout_data->timeout_id > 0) |
| 50 |
g_source_remove(timeout_data->timeout_id); |
| 51 |
|
| 52 |
|
| 53 |
g_free(timeout_data); |
| 54 |
} |
| 55 |
|
| 56 |
GtkWidget *create_iface_waiting_main(struct alsa_card *card) { |
| 57 |
struct timeout_data *data; |
| 58 |
|
| 59 |
|
| 60 |
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20); |
| 61 |
gtk_widget_set_margin_start(box, 40); |
| 62 |
gtk_widget_set_margin_end(box, 40); |
| 63 |
gtk_widget_set_margin_top(box, 40); |
| 64 |
gtk_widget_set_margin_bottom(box, 40); |
| 65 |
|
| 66 |
|
| 67 |
GtkWidget *label = gtk_label_new(NULL); |
| 68 |
gtk_label_set_markup(GTK_LABEL(label), |
| 69 |
"<span weight='bold' size='large'>Waiting for FCP Server</span>"); |
| 70 |
gtk_box_append(GTK_BOX(box), label); |
| 71 |
|
| 72 |
|
| 73 |
GtkWidget *picture_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); |
| 74 |
gtk_widget_set_hexpand(picture_box, TRUE); |
| 75 |
gtk_widget_set_halign(picture_box, GTK_ALIGN_CENTER); |
| 76 |
|
| 77 |
GtkWidget *picture = gtk_picture_new_for_resource( |
| 78 |
"/vu/b4/alsa-scarlett-gui/icons/vu.b4.alsa-scarlett-gui.png" |
| 79 |
); |
| 80 |
gtk_picture_set_can_shrink(GTK_PICTURE(picture), TRUE); |
| 81 |
gtk_widget_set_size_request(picture, 128, 128); |
| 82 |
|
| 83 |
gtk_box_append(GTK_BOX(picture_box), picture); |
| 84 |
gtk_box_append(GTK_BOX(box), picture_box); |
| 85 |
|
| 86 |
|
| 87 |
GtkWidget *spinner = gtk_spinner_new(); |
| 88 |
gtk_spinner_start(GTK_SPINNER(spinner)); |
| 89 |
gtk_widget_set_size_request(spinner, 48, 48); |
| 90 |
gtk_box_append(GTK_BOX(box), spinner); |
| 91 |
|
| 92 |
|
| 93 |
label = gtk_label_new( |
| 94 |
"Waiting for the user-space FCP driver to initialise..." |
| 95 |
); |
| 96 |
gtk_label_set_wrap(GTK_LABEL(label), TRUE); |
| 97 |
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); |
| 98 |
gtk_label_set_max_width_chars(GTK_LABEL(label), 1); |
| 99 |
gtk_widget_set_hexpand(label, TRUE); |
| 100 |
gtk_widget_set_halign(label, GTK_ALIGN_FILL); |
| 101 |
|
| 102 |
gtk_box_append(GTK_BOX(box), label); |
| 103 |
|
| 104 |
|
| 105 |
data = g_new(struct timeout_data, 1); |
| 106 |
data->box = box; |
| 107 |
data->spinner = spinner; |
| 108 |
data->message_label = label; |
| 109 |
|
| 110 |
|
| 111 |
data->timeout_id = g_timeout_add_seconds(5, on_timeout, data); |
| 112 |
|
| 113 |
|
| 114 |
g_object_weak_ref(G_OBJECT(box), on_widget_dispose, data); |
| 115 |
|
| 116 |
return box; |
| 117 |
} |