gui/gst: Use C-style gtk widgets
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
44d7f9a853
commit
f31a67f644
110
gui/gst.cpp
110
gui/gst.cpp
|
@ -15,29 +15,31 @@ extern "C" {
|
|||
#include <gst/gst.h>
|
||||
|
||||
|
||||
static Gtk::Button *o_next;
|
||||
static Gtk::Button *o_pause;
|
||||
static Gtk::Button *o_play;
|
||||
static Gtk::Button *o_prev;
|
||||
static Gtk::Scale *o_seek;
|
||||
static Gtk::Button *o_stop;
|
||||
static GtkButton *o_next;
|
||||
static GtkButton *o_pause;
|
||||
static GtkButton *o_play;
|
||||
static GtkButton *o_prev;
|
||||
static GtkScale *o_seek;
|
||||
static GtkButton *o_stop;
|
||||
|
||||
static Gtk::SpinButton *o_count;
|
||||
static Gtk::CheckButton *o_enabled;
|
||||
static GtkSpinButton *o_count;
|
||||
static GtkToggleButton *o_enabled;
|
||||
|
||||
static Gtk::Label *o_album;
|
||||
static Gtk::Label *o_artist;
|
||||
static Gtk::Label *o_duration;
|
||||
static Gtk::Label *o_position;
|
||||
static Gtk::Label *o_title;
|
||||
static Glib::RefPtr<Gtk::Adjustment> o_progress;
|
||||
static GtkLabel *o_album;
|
||||
static GtkLabel *o_artist;
|
||||
static GtkLabel *o_duration;
|
||||
static GtkLabel *o_position;
|
||||
static GtkLabel *o_title;
|
||||
static GtkAdjustment *o_progress;
|
||||
|
||||
|
||||
static void set_markup(Gtk::Label *label, const std::string &size,
|
||||
static void set_markup(GtkLabel *label, const std::string &size,
|
||||
const std::string &text)
|
||||
{
|
||||
label->set_markup("<span size='" + size + "'>" +
|
||||
Glib::Markup::escape_text(text) + "</span>");
|
||||
gchar *markup = g_markup_printf_escaped("<span size='%s'>%s</span>",
|
||||
size.c_str(), text.c_str());
|
||||
gtk_label_set_markup(label, markup);
|
||||
g_free(markup);
|
||||
}
|
||||
|
||||
static void on_load(struct track *track)
|
||||
|
@ -55,7 +57,7 @@ static void on_load(struct track *track)
|
|||
set_markup(o_title, "xx-large", track->tr_title);
|
||||
|
||||
str = string_sec2str(track->tr_length);
|
||||
o_duration->set_text(str);
|
||||
gtk_label_set_text(o_duration, str);
|
||||
g_free(str);
|
||||
|
||||
toggle = Glib :: wrap(GTK_TOGGLE_BUTTON(gui_builder_widget("o_ban")), false);
|
||||
|
@ -68,21 +70,21 @@ static void on_load(struct track *track)
|
|||
static void on_change_state(GstState state)
|
||||
{
|
||||
if (state == GST_STATE_PLAYING) {
|
||||
o_play->hide();
|
||||
o_pause->show();
|
||||
gtk_widget_hide(GTK_WIDGET(o_play));
|
||||
gtk_widget_show(GTK_WIDGET(o_pause));
|
||||
} else {
|
||||
o_play->show();
|
||||
o_pause->hide();
|
||||
gtk_widget_show(GTK_WIDGET(o_play));
|
||||
gtk_widget_hide(GTK_WIDGET(o_pause));
|
||||
}
|
||||
}
|
||||
|
||||
static void on_config_pause(int n)
|
||||
{
|
||||
if (n == -1)
|
||||
o_enabled->set_active(false);
|
||||
gtk_toggle_button_set_active(o_enabled, false);
|
||||
else {
|
||||
o_count->set_value(n);
|
||||
o_enabled->set_active(true);
|
||||
gtk_spin_button_set_value(o_count, n);
|
||||
gtk_toggle_button_set_active(o_enabled, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,25 +104,25 @@ static bool on_seek(Gtk::ScrollType type, double value)
|
|||
|
||||
static void on_pause_count()
|
||||
{
|
||||
o_enabled->set_active(true);
|
||||
audio_pause_after(o_count->get_value());
|
||||
gtk_toggle_button_set_active(o_enabled, true);
|
||||
audio_pause_after(gtk_spin_button_get_value(o_count));
|
||||
}
|
||||
|
||||
static void on_pause_enabled()
|
||||
{
|
||||
if (!o_enabled->get_active())
|
||||
if (!gtk_toggle_button_get_active(o_enabled))
|
||||
audio_pause_after(-1);
|
||||
else
|
||||
audio_pause_after(o_count->get_value());
|
||||
audio_pause_after(gtk_spin_button_get_value(o_count));
|
||||
}
|
||||
|
||||
static bool on_timeout()
|
||||
{
|
||||
gchar *pos = string_sec2str(audio_position() / GST_SECOND);
|
||||
|
||||
o_progress->set_upper(audio_duration());
|
||||
o_progress->set_value(audio_position());
|
||||
o_position->set_text(pos);
|
||||
gtk_adjustment_set_upper(o_progress, audio_duration());
|
||||
gtk_adjustment_set_value(o_progress, audio_position());
|
||||
gtk_label_set_text(o_position, pos);
|
||||
g_free(pos);
|
||||
return true;
|
||||
}
|
||||
|
@ -141,32 +143,32 @@ void gst :: toggle()
|
|||
|
||||
void gst :: init_pre()
|
||||
{
|
||||
o_next = Glib :: wrap(GTK_BUTTON(gui_builder_widget("o_next")), false);
|
||||
o_pause = Glib :: wrap(GTK_BUTTON(gui_builder_widget("o_pause")), false);
|
||||
o_play = Glib :: wrap(GTK_BUTTON(gui_builder_widget("o_play")), false);
|
||||
o_prev = Glib :: wrap(GTK_BUTTON(gui_builder_widget("o_prev")), false);
|
||||
o_stop = Glib :: wrap(GTK_BUTTON(gui_builder_widget("o_stop")), false);
|
||||
o_seek = Glib :: wrap(GTK_SCALE(gui_builder_widget("o_seek")), false);
|
||||
o_next = GTK_BUTTON(gui_builder_widget("o_next"));
|
||||
o_pause = GTK_BUTTON(gui_builder_widget("o_pause"));
|
||||
o_play = GTK_BUTTON(gui_builder_widget("o_play"));
|
||||
o_prev = GTK_BUTTON(gui_builder_widget("o_prev"));
|
||||
o_stop = GTK_BUTTON(gui_builder_widget("o_stop"));
|
||||
o_seek = GTK_SCALE(gui_builder_widget("o_seek"));
|
||||
|
||||
o_count = Glib :: wrap(GTK_SPIN_BUTTON(gui_builder_widget("o_pause_count")), false);
|
||||
o_enabled = Glib :: wrap(GTK_CHECK_BUTTON(gui_builder_widget("o_pause_enabled")), false);
|
||||
o_count = GTK_SPIN_BUTTON(gui_builder_widget("o_pause_count"));
|
||||
o_enabled = GTK_TOGGLE_BUTTON(gui_builder_widget("o_pause_enabled"));
|
||||
|
||||
o_album = Glib :: wrap(GTK_LABEL(gui_builder_widget("o_album")), false);
|
||||
o_artist = Glib :: wrap(GTK_LABEL(gui_builder_widget("o_artist")), false);
|
||||
o_duration = Glib :: wrap(GTK_LABEL(gui_builder_widget("o_duration")), false);
|
||||
o_position = Glib :: wrap(GTK_LABEL(gui_builder_widget("o_position")), false);
|
||||
o_title = Glib ::wrap(GTK_LABEL(gui_builder_widget("o_title")), false);
|
||||
o_progress = Glib :: wrap(GTK_ADJUSTMENT(gui_builder_object("o_progress")), false);
|
||||
o_album = GTK_LABEL(gui_builder_widget("o_album"));
|
||||
o_artist = GTK_LABEL(gui_builder_widget("o_artist"));
|
||||
o_duration = GTK_LABEL(gui_builder_widget("o_duration"));
|
||||
o_position = GTK_LABEL(gui_builder_widget("o_position"));
|
||||
o_title = GTK_LABEL(gui_builder_widget("o_title"));
|
||||
o_progress = GTK_ADJUSTMENT(gui_builder_object("o_progress"));
|
||||
|
||||
o_next->signal_clicked().connect(sigc::ptr_fun(next));
|
||||
o_pause->signal_clicked().connect(sigc::ptr_fun(gst :: pause));
|
||||
o_play->signal_clicked().connect(sigc::ptr_fun(gst :: play));
|
||||
o_prev->signal_clicked().connect(sigc::ptr_fun(gst :: prev));
|
||||
o_seek->signal_change_value().connect(sigc::ptr_fun(on_seek));
|
||||
o_stop->signal_clicked().connect(sigc::ptr_fun(gst :: stop));
|
||||
g_signal_connect(o_next, "clicked", gst :: next, NULL);
|
||||
g_signal_connect(o_pause, "clicked", gst :: pause, NULL);
|
||||
g_signal_connect(o_play, "clicked", gst :: play, NULL);
|
||||
g_signal_connect(o_prev, "clicked", gst :: prev, NULL);
|
||||
g_signal_connect(o_seek, "change-value", G_CALLBACK(on_seek), NULL);
|
||||
g_signal_connect(o_stop, "clicked", gst :: stop, NULL);
|
||||
|
||||
o_count->signal_changed().connect(sigc::ptr_fun(on_pause_count));
|
||||
o_enabled->signal_toggled().connect(sigc::ptr_fun(on_pause_enabled));
|
||||
g_signal_connect(o_count, "changed", G_CALLBACK(on_pause_count), NULL);
|
||||
g_signal_connect(o_enabled, "toggled", G_CALLBACK(on_pause_enabled), NULL);
|
||||
}
|
||||
|
||||
void gst :: init()
|
||||
|
|
Loading…
Reference in New Issue