2 * Copyright (C) 2008 Rov Juvano <rovjuvano@users.sourceforge.net>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include <glib/gprintf.h>
28 #define G_LOG_DOMAIN "demo-gui"
30 #if !GTK_CHECK_VERSION(2,12,0)
31 #define gtk_widget_error_bell(w) /* nop */
40 static guint demo_gui_signals[LAST_SIGNAL] = { 0 };
47 typedef struct _DemoGuiPrivate
55 GtkStatusbar *status_bar;
56 gint position_updater_id;
58 GtkLabel *amount_played;
59 GtkLabel *amount_to_play;
60 GtkAction *play_action;
61 GtkAction *pause_action;
63 GtkAction *playlist_next;
66 #define DEMO_GUI_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEMO_TYPE_GUI, DemoGuiPrivate))
68 /* forward declarations */
69 static GValueArray *build_gvalue_array (guint n_values, ...);
71 /* Handlers for status bar and seek bar */
73 pop_status_bar (gpointer data)
75 GValueArray *gvalues = (GValueArray *) data;
77 GTK_STATUSBAR (g_value_get_object (g_value_array_get_nth (gvalues, 0)));
78 guint msg_id = g_value_get_uint (g_value_array_get_nth (gvalues, 1));
80 gtk_statusbar_remove (sb, 0, msg_id);
84 #define DEFAULT_STATUS_BAR_TIMEOUT 2
86 status_bar_printf (GtkStatusbar * sb, guint seconds, gchar const *format, ...)
92 va_start (args, format);
93 g_vsnprintf (msg, 80, format, args);
96 msg_id = gtk_statusbar_push (sb, 0, msg);
97 g_timeout_add (2000, pop_status_bar,
98 build_gvalue_array (2, G_TYPE_OBJECT, sb, G_TYPE_UINT, msg_id));
101 #define PRINTF_TIME_FORMAT "u:%02u:%02u"
102 #define PRINTF_TIME_ARGS(t) \
103 (t >= 0) ? (guint) ((t) / (60 * 60)) : 99, \
104 (t >= 0) ? (guint) (((t) / (60)) % 60) : 99, \
105 (t >= 0) ? (guint) ((t) % 60) : 99
108 demo_gui_seek_bar_format (GtkScale * scale, gdouble value, gpointer data)
110 return g_strdup_printf ("%" PRINTF_TIME_FORMAT,
111 PRINTF_TIME_ARGS ((gint64) value));
115 update_position (gpointer data)
117 DemoGui *gui = DEMO_GUI (data);
118 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
119 gchar pos_str[16], dur_str[16];
120 gint pos = demo_player_get_position (priv->player);
123 gint dur = demo_player_get_duration (priv->player);
125 g_snprintf (pos_str, 16, "%" PRINTF_TIME_FORMAT, PRINTF_TIME_ARGS (pos));
127 g_snprintf (dur_str, 16, "-%" PRINTF_TIME_FORMAT,
128 PRINTF_TIME_ARGS (dur - pos));
131 g_sprintf (dur_str, "-??:??:??");
134 gtk_range_set_range (GTK_RANGE (priv->seek_range), 0, (gdouble) dur);
135 gtk_range_set_value (GTK_RANGE (priv->seek_range), (gdouble) pos);
137 g_sprintf (pos_str, "??:??:??");
138 g_sprintf (dur_str, "-??:??:??");
140 gtk_label_set_text (GTK_LABEL (priv->amount_played), pos_str);
141 gtk_label_set_text (GTK_LABEL (priv->amount_to_play), dur_str);
143 return priv->is_playing;
148 demo_gui_seek_bar_change (GtkRange * range,
149 GtkScrollType scroll, gdouble value, gpointer data)
151 DemoGui *gui = DEMO_GUI (data);
152 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
153 gint new_second = (gint) value;
155 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
156 "Seeking to %i second", new_second);
157 demo_player_seek_to (priv->player, new_second);
163 /* Callbacks for actions */
165 demo_gui_do_change_rate (GtkAction * action, gpointer data)
167 GValueArray *gvalues = (GValueArray *) data;
168 DemoGui *gui = g_value_get_object (g_value_array_get_nth (gvalues, 0));
169 gdouble scale_amount =
170 g_value_get_double (g_value_array_get_nth (gvalues, 1));
171 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
173 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
174 "Changing rate by %3.2lf", scale_amount);
176 demo_player_scale_rate (priv->player, scale_amount);
180 demo_gui_do_set_rate (GtkAction * action, gpointer data)
182 GValueArray *gvalues = (GValueArray *) data;
183 DemoGui *gui = g_value_get_object (g_value_array_get_nth (gvalues, 0));
184 gdouble new_rate = g_value_get_double (g_value_array_get_nth (gvalues, 1));
185 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
187 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
188 "Setting rate to %3.2lf", new_rate);
190 demo_player_set_rate (priv->player, new_rate);
194 demo_gui_do_rate_entered (GtkWidget * widget, gpointer data)
196 DemoGui *gui = DEMO_GUI (data);
197 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
199 const gchar *text = gtk_entry_get_text (GTK_ENTRY (widget));
200 double new_rate = g_strtod (text, &err);
203 gtk_widget_error_bell (priv->window);
204 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
205 "Invalid rate: %s", text);
209 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
210 "Setting rate to %3.2lf", new_rate);
212 demo_player_set_rate (priv->player, new_rate);
217 demo_gui_do_toggle_advanced (GtkAction * action, gpointer data)
219 GValueArray *gvalues = (GValueArray *) data;
221 DEMO_GUI (g_value_get_object (g_value_array_get_nth (gvalues, 0)));
222 GtkWidget *stride_ui =
223 GTK_WIDGET (g_value_get_object (g_value_array_get_nth (gvalues, 1)));
224 GtkWidget *overlap_ui =
225 GTK_WIDGET (g_value_get_object (g_value_array_get_nth (gvalues, 2)));
226 GtkWidget *search_ui =
227 GTK_WIDGET (g_value_get_object (g_value_array_get_nth (gvalues, 3)));
228 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
231 status_bar_printf (priv->status_bar, 1, "Toggling advanced mode");
233 active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
234 gtk_widget_set_sensitive (stride_ui, active);
235 gtk_widget_set_sensitive (overlap_ui, active);
236 gtk_widget_set_sensitive (search_ui, active);
240 demo_gui_do_toggle_disabled (GtkAction * action, gpointer data)
242 GValueArray *gvalues = (GValueArray *) data;
244 DEMO_GUI (g_value_get_object (g_value_array_get_nth (gvalues, 0)));
245 GtkAction *advanced_action =
246 GTK_ACTION (g_value_get_object (g_value_array_get_nth (gvalues, 1)));
247 GtkWidget *advanced_ui =
248 GTK_WIDGET (g_value_get_object (g_value_array_get_nth (gvalues, 2)));
250 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
253 status_bar_printf (priv->status_bar, 1, "Toggling disabled");
255 active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
256 gtk_action_set_sensitive (GTK_ACTION (advanced_action), !active);
257 gtk_widget_set_sensitive (GTK_WIDGET (advanced_ui), !active);
258 g_object_set (G_OBJECT (priv->player), "disabled", active, NULL);
262 demo_gui_do_seek (GtkAction * action, gpointer data)
264 GValueArray *gvalues = (GValueArray *) data;
266 DEMO_GUI (g_value_get_object (g_value_array_get_nth (gvalues, 0)));
267 gint seconds = g_value_get_int (g_value_array_get_nth (gvalues, 1));
268 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
270 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
271 "Requesting seek by %i seconds", seconds);
273 demo_player_seek_by (priv->player, seconds);
277 demo_gui_do_play (GtkAction * action, gpointer data)
279 DemoGui *gui = DEMO_GUI (data);
280 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
282 if (priv->is_playing) {
283 g_signal_emit (gui, demo_gui_signals[SIGNAL_ERROR], 0, "Already playing");
287 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
288 "Requesting playback start");
290 demo_player_play (priv->player);
294 demo_gui_do_pause (GtkAction * action, gpointer data)
296 DemoGui *gui = DEMO_GUI (data);
297 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
299 if (!priv->is_playing) {
300 g_signal_emit (gui, demo_gui_signals[SIGNAL_ERROR], 0, "Already paused");
304 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
305 "Requesting playback pause");
307 demo_player_pause (priv->player);
311 demo_gui_do_play_pause (GtkAction * action, gpointer data)
313 DemoGui *gui = DEMO_GUI (data);
314 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
316 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
317 "Reqesting playback toggle");
319 if (priv->is_playing)
320 gtk_action_activate (priv->pause_action);
322 gtk_action_activate (priv->play_action);
326 demo_gui_do_open_file (GtkAction * action, gpointer data)
328 DemoGui *gui = DEMO_GUI (data);
329 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
330 GtkWidget *dialog = gtk_file_chooser_dialog_new ("Open File",
331 GTK_WINDOW (priv->window),
332 GTK_FILE_CHOOSER_ACTION_OPEN,
333 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
334 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
337 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
338 char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
341 g_list_free (priv->uris);
343 priv->now_playing = NULL;
344 demo_player_load_uri (priv->player, g_filename_to_uri (filename, NULL,
348 gtk_widget_destroy (dialog);
352 demo_gui_do_playlist_prev (GtkAction * action, gpointer data)
354 DemoGui *gui = DEMO_GUI (data);
355 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
357 if (priv->now_playing) {
358 if (priv->now_playing->prev) {
359 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
360 "Playlist previous");
361 priv->now_playing = priv->now_playing->prev;
363 priv->now_playing = NULL;
364 gtk_widget_error_bell (priv->window);
365 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
366 "Beginning of playlist");
369 } else if (priv->uris) {
370 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
371 "Playlist previous: wrap");
372 priv->now_playing = g_list_last (priv->uris);
374 gtk_action_activate (priv->open_file);
378 demo_player_load_uri (priv->player, priv->now_playing->data);
382 demo_gui_do_playlist_next (GtkAction * action, gpointer data)
384 DemoGui *gui = DEMO_GUI (data);
385 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
387 if (priv->now_playing) {
388 if (priv->now_playing->next) {
389 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
391 priv->now_playing = priv->now_playing->next;
393 priv->now_playing = NULL;
394 gtk_widget_error_bell (priv->window);
395 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
399 } else if (priv->uris) {
400 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
401 "Playlist next: wrap");
402 priv->now_playing = priv->uris;
404 gtk_action_activate (priv->open_file);
408 demo_player_load_uri (priv->player, priv->now_playing->data);
412 demo_gui_do_about_dialog (GtkAction * action, gpointer data)
414 static gchar *authors[] =
415 { "Rov Juvano <rovjuvano@users.sourceforge.net>", NULL };
417 gtk_show_about_dialog (NULL,
418 "program-name", "gst-scaletempo-demo",
421 "license", "This program is free software: you can redistribute it and/or modify\n\
422 it under the terms of the GNU General Public License as published by\n\
423 the Free Software Foundation, either version 3 of the License, or\n\
424 (at your option) any later version.\n\
426 This program is distributed in the hope that it will be useful,\n\
427 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
428 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
429 GNU General Public License for more details.\n\
431 You should have received a copy of the GNU General Public License\n\
432 along with this program. If not, see <http://www.gnu.org/licenses/>.", "title", "About gst-scaletempo-demo", NULL);
436 demo_gui_do_quit (gpointer source, gpointer data)
439 g_signal_emit (DEMO_GUI (data), demo_gui_signals[SIGNAL_QUITING], 0, NULL);
443 demo_gui_request_set_stride (GtkSpinButton * spinbutton, gpointer data)
445 DemoGui *gui = DEMO_GUI (data);
446 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
447 guint new_stride = gtk_spin_button_get_value_as_int (spinbutton);
449 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
450 "Reqesting setting stride to %u ms", new_stride);
451 g_object_set (G_OBJECT (priv->player), "stride", new_stride, NULL);
456 demo_gui_request_set_overlap (GtkSpinButton * spinbutton, gpointer data)
458 DemoGui *gui = DEMO_GUI (data);
459 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
460 gdouble new_overlap = gtk_spin_button_get_value_as_int (spinbutton);
462 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
463 "Requesting setting overlap to %2.0lf%%", new_overlap);
464 g_object_set (G_OBJECT (priv->player), "overlap", new_overlap / 100.0, NULL);
469 demo_gui_request_set_search (GtkSpinButton * spinbutton, gpointer data)
471 DemoGui *gui = DEMO_GUI (data);
472 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
473 guint new_search = gtk_spin_button_get_value_as_int (spinbutton);
475 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
476 "Requesting setting search to %u ms", new_search);
477 g_object_set (G_OBJECT (priv->player), "search", new_search, NULL);
482 /* Callbacks from signals */
484 demo_gui_rate_changed (DemoPlayer * player, gdouble new_rate, gpointer data)
486 DemoGui *gui = DEMO_GUI (data);
487 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
490 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
491 "Rate changed to %3.2lf", new_rate);
493 g_snprintf (e, 6, "%3.2f", new_rate);
494 gtk_entry_set_text (GTK_ENTRY (priv->rate_entry), e);
498 demo_gui_playing_started (DemoPlayer * player, gpointer data)
500 DemoGui *gui = DEMO_GUI (data);
501 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
503 priv->is_playing = TRUE;
504 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
507 gtk_action_set_sensitive (priv->play_action, FALSE);
508 gtk_action_set_sensitive (priv->pause_action, TRUE);
509 gtk_action_set_visible (priv->play_action, FALSE);
510 gtk_action_set_visible (priv->pause_action, TRUE);
512 if (priv->position_updater_id) {
513 g_source_remove (priv->position_updater_id);
514 priv->position_updater_id = 0;
516 update_position (gui);
517 priv->position_updater_id = g_timeout_add (1000, update_position, gui);
521 demo_gui_playing_paused (DemoPlayer * player, gpointer data)
523 DemoGui *gui = DEMO_GUI (data);
524 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
526 gtk_action_set_sensitive (priv->play_action, TRUE);
527 gtk_action_set_sensitive (priv->pause_action, FALSE);
528 gtk_action_set_visible (priv->play_action, TRUE);
529 gtk_action_set_visible (priv->pause_action, FALSE);
531 priv->is_playing = FALSE;
533 if (priv->position_updater_id)
534 g_source_remove (priv->position_updater_id);
535 priv->position_updater_id = 0;
536 update_position (gui);
538 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
543 demo_gui_playing_ended (DemoPlayer * player, gpointer data)
545 DemoGui *gui = DEMO_GUI (data);
546 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
548 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
550 gtk_action_activate (priv->playlist_next);
554 demo_gui_player_errored (DemoPlayer * player, const gchar * msg, gpointer data)
556 DemoGui *gui = DEMO_GUI (data);
557 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
559 status_bar_printf (priv->status_bar, 5, msg);
563 demo_gui_stride_changed (DemoPlayer * player, GParamSpec * pspec, gpointer data)
565 GValueArray *gvalues = (GValueArray *) data;
567 DEMO_GUI (g_value_get_object (g_value_array_get_nth (gvalues, 0)));
569 GTK_ENTRY (g_value_get_object (g_value_array_get_nth (gvalues, 1)));
570 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
574 g_object_get (G_OBJECT (player), "stride", &new_stride, NULL);
575 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
576 "Stride changed to %u", new_stride);
578 snprintf (e, 6, "%u", new_stride);
579 gtk_entry_set_text (entry, e);
583 demo_gui_overlap_changed (DemoPlayer * player,
584 GParamSpec * pspec, gpointer data)
586 GValueArray *gvalues = (GValueArray *) data;
588 DEMO_GUI (g_value_get_object (g_value_array_get_nth (gvalues, 0)));
590 GTK_ENTRY (g_value_get_object (g_value_array_get_nth (gvalues, 1)));
591 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
595 g_object_get (G_OBJECT (player), "overlap", &new_overlap, NULL);
597 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
598 "Overlap changed to %2.0lf%%", new_overlap);
600 snprintf (e, 6, "%2.0f", new_overlap);
601 gtk_entry_set_text (entry, e);
605 demo_gui_search_changed (DemoPlayer * player, GParamSpec * pspec, gpointer data)
607 GValueArray *gvalues = (GValueArray *) data;
609 DEMO_GUI (g_value_get_object (g_value_array_get_nth (gvalues, 0)));
611 GTK_ENTRY (g_value_get_object (g_value_array_get_nth (gvalues, 1)));
612 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
616 g_object_get (G_OBJECT (player), "search", &new_search, NULL);
617 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
618 "Search changed to %u", new_search);
620 snprintf (e, 6, "%u", new_search);
621 gtk_entry_set_text (entry, e);
625 /* method implementations */
627 demo_gui_set_player_func (DemoGui * gui, DemoPlayer * player)
629 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
632 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->player),
633 G_CALLBACK (demo_gui_rate_changed), gui);
634 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->player),
635 G_CALLBACK (demo_gui_playing_started), gui);
636 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->player),
637 G_CALLBACK (demo_gui_playing_paused), gui);
638 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->player),
639 G_CALLBACK (demo_gui_playing_ended), gui);
640 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->player),
641 G_CALLBACK (demo_gui_player_errored), gui);
642 g_object_unref (priv->player);
644 g_object_ref (player);
645 priv->player = player;
646 g_signal_connect (G_OBJECT (priv->player), "error",
647 G_CALLBACK (demo_gui_player_errored), gui);
648 g_signal_connect (G_OBJECT (priv->player), "rate-changed",
649 G_CALLBACK (demo_gui_rate_changed), gui);
650 g_signal_connect (G_OBJECT (priv->player), "playing-started",
651 G_CALLBACK (demo_gui_playing_started), gui);
652 g_signal_connect (G_OBJECT (priv->player), "playing-paused",
653 G_CALLBACK (demo_gui_playing_paused), gui);
654 g_signal_connect (G_OBJECT (priv->player), "playing-ended",
655 G_CALLBACK (demo_gui_playing_ended), gui);
656 priv->is_playing = FALSE;
660 demo_gui_set_playlist_func (DemoGui * gui, GList * uris)
662 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
666 typedef struct _ActionEntry
673 const gchar *tooltip;
674 const gchar *stock_id;
675 GtkAccelGroup *accel_group;
676 GtkActionGroup *action_group;
682 build_gvalue_array (guint n_values, ...)
688 va_start (args, n_values);
689 gva = g_value_array_new (n_values);
691 for (i = 0; i < n_values; i++) {
692 GType type = va_arg (args, GType);
693 GValue *gval = g_new0 (GValue, 1);
694 if (type == G_TYPE_INT) {
695 gint value = va_arg (args, gint);
696 g_value_set_int (g_value_init (gval, G_TYPE_INT), value);
697 } else if (type == G_TYPE_UINT) {
698 guint value = va_arg (args, guint);
699 g_value_set_uint (g_value_init (gval, G_TYPE_UINT), value);
700 } else if (type == G_TYPE_DOUBLE) {
701 double value = va_arg (args, double);
702 g_value_set_double (g_value_init (gval, G_TYPE_DOUBLE), value);
703 } else if (type == G_TYPE_OBJECT) {
704 GObject *value = va_arg (args, GObject *);
705 g_value_set_object (g_value_init (gval, G_TYPE_OBJECT), value);
707 g_critical ("build_gvalue_array cannot handle type (%s)",
712 g_value_array_append (gva, gval);
719 create_action (ActionEntry * p)
721 p->action = gtk_action_new (p->name, p->label, p->tooltip, p->stock_id);
723 gtk_action_group_add_action_with_accel (p->action_group, p->action, p->accel);
724 gtk_action_set_accel_group (p->action, p->accel_group);
725 gtk_action_connect_accelerator (p->action);
727 p->button = gtk_button_new ();
728 gtk_action_connect_proxy (p->action, p->button);
729 gtk_button_set_image (GTK_BUTTON (p->button),
730 gtk_action_create_icon (p->action, GTK_ICON_SIZE_BUTTON));
731 g_signal_connect (G_OBJECT (p->action), "activate", p->callback, p->data);
735 demo_gui_show_func (DemoGui * gui)
737 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
739 GtkAccelGroup *accel_group;
740 GtkActionGroup *action_group;
741 GtkAction *toggle_advanced, *toggle_disabled;
742 ActionEntry *slower_lg, *slower_sm, *faster_sm, *faster_lg, *normal,
743 *rewind_lg, *rewind_sm, *forward_sm, *forward_lg, *pause, *play,
744 *play_pause, *open_file, *playlist_prev, *playlist_next, *quit, *about;
745 GtkRequisition pause_size;
746 GtkWidget *rate_entry, *rate_label, *toolbox, *stride_ui, *overlap_ui,
747 *search_ui, *propbox, *adv_check, *disabled_check, *media_controls,
748 *amount_played, *amount_to_play, *seek_range, *seek_bar, *status_bar,
749 *file_menu, *file_menu_item, *media_menu_item, *demo_menu,
750 *demo_menu_item, *menu_bar, *toplevel_box, *media_menu;
751 GError *error = NULL;
753 gtk_init (NULL, NULL);
754 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
755 g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (demo_gui_do_quit),
758 accel_group = gtk_accel_group_new ();
759 gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
760 action_group = gtk_action_group_new ("toolbar");
762 slower_lg = &(ActionEntry) {
764 "braceleft", "slower-large",
765 "2x Slower", "half playback rate",
766 GTK_STOCK_GO_DOWN, accel_group, action_group,
767 G_CALLBACK (demo_gui_do_change_rate),
768 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_DOUBLE, 0.5)
770 create_action (slower_lg);
772 slower_sm = &(ActionEntry) {
774 "bracketleft", "slower-small",
775 "_Slower", "decrease playback rate",
776 GTK_STOCK_GO_DOWN, accel_group, action_group,
777 G_CALLBACK (demo_gui_do_change_rate),
778 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_DOUBLE, pow (2,
781 create_action (slower_sm);
783 faster_sm = &(ActionEntry) {
785 "bracketright", "faster-small",
786 "_Faster", "increase playback rate",
787 GTK_STOCK_GO_UP, accel_group, action_group,
788 G_CALLBACK (demo_gui_do_change_rate),
789 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_DOUBLE, pow (2,
792 create_action (faster_sm);
794 faster_lg = &(ActionEntry) {
796 "braceright", "faster-large",
797 "2X Faster", "double playback rate",
798 GTK_STOCK_GO_UP, accel_group, action_group,
799 G_CALLBACK (demo_gui_do_change_rate),
800 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_DOUBLE, 2.0)
802 create_action (faster_lg);
804 normal = &(ActionEntry) {
806 "backslash", "normal",
807 "_Normal", "playback normal rate",
808 GTK_STOCK_CLEAR, accel_group, action_group,
809 G_CALLBACK (demo_gui_do_set_rate),
810 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_DOUBLE, 1.0)
812 create_action (normal);
814 rewind_lg = &(ActionEntry) {
816 "<ctrl><shift>Left", "seek-rewind-large",
817 "Rewind (large)", "seek -30 seconds",
818 GTK_STOCK_MEDIA_REWIND, accel_group, action_group,
819 G_CALLBACK (demo_gui_do_seek),
820 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_INT, -30)
822 create_action (rewind_lg);
824 rewind_sm = &(ActionEntry) {
826 "<ctrl>Left", "seek-rewind-small",
827 "Rewind", "seek -15 seconds",
828 GTK_STOCK_MEDIA_REWIND, accel_group, action_group,
829 G_CALLBACK (demo_gui_do_seek),
830 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_INT, -5)
832 create_action (rewind_sm);
834 forward_sm = &(ActionEntry) {
836 "<ctrl>Right", "seek-forward-small",
837 "Forward", "seek +5 seconds",
838 GTK_STOCK_MEDIA_FORWARD, accel_group, action_group,
839 G_CALLBACK (demo_gui_do_seek),
840 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_INT, 5)
842 create_action (forward_sm);
844 forward_lg = &(ActionEntry) {
846 "<ctrl><shift>Right", "seek-forward-large",
847 "Forward (large)", "seek +30 seconds",
848 GTK_STOCK_MEDIA_FORWARD, accel_group, action_group,
849 G_CALLBACK (demo_gui_do_seek),
850 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_INT, 30)
852 create_action (forward_lg);
854 pause = &(ActionEntry) {
857 "Pause", "Pause playback",
858 GTK_STOCK_MEDIA_PAUSE, accel_group, action_group,
859 G_CALLBACK (demo_gui_do_pause), gui};
860 create_action (pause);
862 play = &(ActionEntry) {
865 "Play", "Start Playback",
866 GTK_STOCK_MEDIA_PLAY, accel_group, action_group,
867 G_CALLBACK (demo_gui_do_play), gui};
868 create_action (play);
869 gtk_widget_size_request (pause->button, &pause_size);
870 gtk_widget_set_size_request (play->button, pause_size.width, -1);
872 play_pause = &(ActionEntry) {
874 "space", "play-pause",
875 "Play/Pause", "Toggle playback",
876 NULL, accel_group, action_group,
877 G_CALLBACK (demo_gui_do_play_pause), gui};
878 create_action (play_pause);
880 open_file = &(ActionEntry) {
882 "<ctrl>o", "open-file",
883 "Open File", "Open file for playing",
884 GTK_STOCK_OPEN, accel_group, action_group,
885 G_CALLBACK (demo_gui_do_open_file), gui};
886 create_action (open_file);
888 playlist_prev = &(ActionEntry) {
890 "less", "playlist-previous",
891 "Previous", "Previous in playlist",
892 GTK_STOCK_MEDIA_PREVIOUS, accel_group, action_group,
893 G_CALLBACK (demo_gui_do_playlist_prev), gui};
894 create_action (playlist_prev);
896 playlist_next = &(ActionEntry) {
898 "greater", "playlist-next",
899 "Next", "Next in playlist",
900 GTK_STOCK_MEDIA_NEXT, accel_group, action_group,
901 G_CALLBACK (demo_gui_do_playlist_next), gui};
902 create_action (playlist_next);
904 quit = &(ActionEntry) {
908 GTK_STOCK_QUIT, accel_group, action_group,
909 G_CALLBACK (demo_gui_do_quit), gui};
910 create_action (quit);
912 about = &(ActionEntry) {
915 "About", "About gst-scaletemo-demo",
916 GTK_STOCK_ABOUT, accel_group, action_group,
917 G_CALLBACK (demo_gui_do_about_dialog), gui};
918 create_action (about);
920 rate_entry = gtk_entry_new ();
921 rate_label = gtk_label_new ("Rate:");
922 gtk_entry_set_max_length (GTK_ENTRY (rate_entry), 5);
923 gtk_entry_set_text (GTK_ENTRY (rate_entry), "1.0");
924 gtk_entry_set_width_chars (GTK_ENTRY (rate_entry), 5);
925 g_signal_connect (G_OBJECT (rate_entry), "activate",
926 G_CALLBACK (demo_gui_do_rate_entered), gui);
928 toolbox = gtk_hbox_new (FALSE, 0);
929 gtk_box_pack_start (GTK_BOX (toolbox), slower_sm->button, FALSE, FALSE, 2);
930 gtk_box_pack_start (GTK_BOX (toolbox), rate_label, FALSE, FALSE, 2);
931 gtk_box_pack_start (GTK_BOX (toolbox), rate_entry, FALSE, FALSE, 2);
932 gtk_box_pack_start (GTK_BOX (toolbox), faster_sm->button, FALSE, FALSE, 2);
933 gtk_box_pack_start (GTK_BOX (toolbox), normal->button, FALSE, FALSE, 2);
937 gtk_spin_button_new (GTK_ADJUSTMENT (gtk_adjustment_new (60, 1, 1000, 1,
940 gtk_spin_button_new (GTK_ADJUSTMENT (gtk_adjustment_new (20, 0, 100, 5,
943 gtk_spin_button_new (GTK_ADJUSTMENT (gtk_adjustment_new (14, 0, 1000, 1,
945 gtk_widget_set_sensitive (stride_ui, FALSE);
946 gtk_widget_set_sensitive (overlap_ui, FALSE);
947 gtk_widget_set_sensitive (search_ui, FALSE);
948 g_signal_connect (G_OBJECT (stride_ui), "output",
949 G_CALLBACK (demo_gui_request_set_stride), gui);
950 g_signal_connect (G_OBJECT (overlap_ui), "output",
951 G_CALLBACK (demo_gui_request_set_overlap), gui);
952 g_signal_connect (G_OBJECT (search_ui), "output",
953 G_CALLBACK (demo_gui_request_set_search), gui);
954 g_signal_connect (G_OBJECT (priv->player), "notify::stride",
955 G_CALLBACK (demo_gui_stride_changed), build_gvalue_array (2,
956 G_TYPE_OBJECT, gui, G_TYPE_OBJECT, stride_ui));
957 g_signal_connect (G_OBJECT (priv->player), "notify::overlap",
958 G_CALLBACK (demo_gui_overlap_changed), build_gvalue_array (2,
959 G_TYPE_OBJECT, gui, G_TYPE_OBJECT, overlap_ui));
960 g_signal_connect (G_OBJECT (priv->player), "notify::search",
961 G_CALLBACK (demo_gui_search_changed), build_gvalue_array (2,
962 G_TYPE_OBJECT, gui, G_TYPE_OBJECT, search_ui));
963 propbox = gtk_hbox_new (FALSE, 0);
964 adv_check = gtk_check_button_new ();
965 gtk_box_pack_start (GTK_BOX (propbox), gtk_label_new ("stride:"), FALSE,
967 gtk_box_pack_start (GTK_BOX (propbox), stride_ui, FALSE, FALSE, 2);
968 gtk_box_pack_start (GTK_BOX (propbox), gtk_label_new ("overlap:"), FALSE,
970 gtk_box_pack_start (GTK_BOX (propbox), overlap_ui, FALSE, FALSE, 2);
971 gtk_box_pack_start (GTK_BOX (propbox), gtk_label_new ("search:"), FALSE,
973 gtk_box_pack_start (GTK_BOX (propbox), search_ui, FALSE, FALSE, 2);
974 gtk_box_pack_start (GTK_BOX (propbox), adv_check, FALSE, FALSE, 2);
977 GTK_ACTION (gtk_toggle_action_new ("advanced", "Enable Parameters",
978 "Toggle advanced controls", 0));
979 gtk_action_group_add_action_with_accel (action_group, toggle_advanced,
981 gtk_action_set_accel_group (toggle_advanced, accel_group);
982 gtk_action_connect_accelerator (toggle_advanced);
983 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (toggle_advanced), FALSE);
984 gtk_action_connect_proxy (toggle_advanced, adv_check);
985 g_signal_connect (G_OBJECT (toggle_advanced), "activate",
986 G_CALLBACK (demo_gui_do_toggle_advanced), build_gvalue_array (4,
987 G_TYPE_OBJECT, gui, G_TYPE_OBJECT, stride_ui, G_TYPE_OBJECT,
988 overlap_ui, G_TYPE_OBJECT, search_ui));
991 GTK_ACTION (gtk_toggle_action_new ("disabled", "Disable Scaletempo",
992 "Toggle disabling scaletempo", 0));
993 gtk_action_group_add_action_with_accel (action_group, toggle_disabled,
995 gtk_action_set_accel_group (toggle_disabled, accel_group);
996 gtk_action_connect_accelerator (toggle_disabled);
997 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (toggle_disabled), FALSE);
998 disabled_check = gtk_check_button_new ();
999 gtk_action_connect_proxy (toggle_disabled, disabled_check);
1000 g_signal_connect (G_OBJECT (toggle_disabled), "activate",
1001 G_CALLBACK (demo_gui_do_toggle_disabled), build_gvalue_array (3,
1002 G_TYPE_OBJECT, gui, G_TYPE_OBJECT, toggle_advanced, G_TYPE_OBJECT,
1004 gtk_box_pack_start (GTK_BOX (toolbox), disabled_check, FALSE, FALSE, 2);
1007 media_controls = gtk_hbox_new (FALSE, 0);
1008 gtk_box_pack_start (GTK_BOX (media_controls), playlist_prev->button, FALSE,
1010 gtk_box_pack_start (GTK_BOX (media_controls), rewind_sm->button, FALSE, FALSE,
1012 gtk_box_pack_start (GTK_BOX (media_controls), play->button, FALSE, FALSE, 2);
1013 gtk_box_pack_start (GTK_BOX (media_controls), pause->button, FALSE, FALSE, 2);
1014 gtk_box_pack_start (GTK_BOX (media_controls), forward_sm->button, FALSE,
1016 gtk_box_pack_start (GTK_BOX (media_controls), playlist_next->button, FALSE,
1019 amount_played = gtk_label_new ("?:??:??");
1020 amount_to_play = gtk_label_new ("-?:??:??");
1021 gtk_label_set_width_chars (GTK_LABEL (amount_played), 8);
1022 gtk_label_set_width_chars (GTK_LABEL (amount_to_play), 8);
1023 gtk_misc_set_alignment (GTK_MISC (amount_played), 1, 1);
1024 gtk_misc_set_alignment (GTK_MISC (amount_to_play), 0, 1);
1026 gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 5.0,
1028 gtk_range_set_update_policy (GTK_RANGE (seek_range),
1029 GTK_UPDATE_DISCONTINUOUS);
1030 seek_bar = gtk_hbox_new (FALSE, 0);
1031 gtk_box_pack_start (GTK_BOX (seek_bar), amount_played, FALSE, FALSE, 2);
1032 gtk_box_pack_start (GTK_BOX (seek_bar), seek_range, TRUE, TRUE, 2);
1033 gtk_box_pack_start (GTK_BOX (seek_bar), amount_to_play, FALSE, FALSE, 2);
1034 g_signal_connect (G_OBJECT (seek_range), "format-value",
1035 G_CALLBACK (demo_gui_seek_bar_format), gui);
1036 g_signal_connect (G_OBJECT (seek_range), "change-value",
1037 G_CALLBACK (demo_gui_seek_bar_change), gui);
1039 status_bar = gtk_statusbar_new ();
1042 file_menu = gtk_menu_new ();
1043 gtk_menu_set_accel_group (GTK_MENU (file_menu), accel_group);
1044 gtk_menu_shell_append (GTK_MENU_SHELL (file_menu),
1045 gtk_action_create_menu_item (open_file->action));
1046 gtk_menu_shell_append (GTK_MENU_SHELL (file_menu),
1047 gtk_action_create_menu_item (about->action));
1048 gtk_menu_shell_append (GTK_MENU_SHELL (file_menu),
1049 gtk_action_create_menu_item (quit->action));
1050 file_menu_item = gtk_menu_item_new_with_mnemonic ("_File");
1051 gtk_menu_item_set_submenu (GTK_MENU_ITEM (file_menu_item), file_menu);
1053 media_menu = gtk_menu_new ();
1054 gtk_menu_set_accel_group (GTK_MENU (media_menu), accel_group);
1055 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1056 gtk_action_create_menu_item (rewind_lg->action));
1057 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1058 gtk_action_create_menu_item (rewind_sm->action));
1059 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1060 gtk_action_create_menu_item (forward_sm->action));
1061 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1062 gtk_action_create_menu_item (forward_lg->action));
1063 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1064 gtk_action_create_menu_item (play->action));
1065 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1066 gtk_action_create_menu_item (pause->action));
1067 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1068 gtk_action_create_menu_item (play_pause->action));
1069 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1070 gtk_action_create_menu_item (playlist_prev->action));
1071 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1072 gtk_action_create_menu_item (playlist_next->action));
1073 media_menu_item = gtk_menu_item_new_with_mnemonic ("_Media");
1074 gtk_menu_item_set_submenu (GTK_MENU_ITEM (media_menu_item), media_menu);
1076 demo_menu = gtk_menu_new ();
1077 gtk_menu_set_accel_group (GTK_MENU (demo_menu), accel_group);
1078 gtk_menu_shell_append (GTK_MENU_SHELL (demo_menu),
1079 gtk_action_create_menu_item (faster_lg->action));
1080 gtk_menu_shell_append (GTK_MENU_SHELL (demo_menu),
1081 gtk_action_create_menu_item (faster_sm->action));
1082 gtk_menu_shell_append (GTK_MENU_SHELL (demo_menu),
1083 gtk_action_create_menu_item (slower_sm->action));
1084 gtk_menu_shell_append (GTK_MENU_SHELL (demo_menu),
1085 gtk_action_create_menu_item (slower_lg->action));
1086 gtk_menu_shell_append (GTK_MENU_SHELL (demo_menu),
1087 gtk_action_create_menu_item (normal->action));
1088 gtk_menu_shell_append (GTK_MENU_SHELL (demo_menu),
1089 gtk_action_create_menu_item (toggle_disabled));
1090 gtk_menu_shell_append (GTK_MENU_SHELL (demo_menu),
1091 gtk_action_create_menu_item (toggle_advanced));
1092 demo_menu_item = gtk_menu_item_new_with_mnemonic ("_Scaletempo");
1093 gtk_menu_item_set_submenu (GTK_MENU_ITEM (demo_menu_item), demo_menu);
1095 menu_bar = gtk_menu_bar_new ();
1096 gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), file_menu_item);
1097 gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), media_menu_item);
1098 gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), demo_menu_item);
1100 /* Toplevel Window */
1101 gtk_window_set_title (GTK_WINDOW (window), "Scaletempo Demo");
1102 toplevel_box = gtk_vbox_new (FALSE, 0);
1103 gtk_container_set_border_width (GTK_CONTAINER (toplevel_box), 3);
1104 gtk_container_add (GTK_CONTAINER (window), toplevel_box);
1105 gtk_box_pack_start (GTK_BOX (toplevel_box), menu_bar, FALSE, FALSE, 2);
1106 gtk_box_pack_start (GTK_BOX (toplevel_box), media_controls, FALSE, FALSE, 2);
1107 gtk_box_pack_start (GTK_BOX (toplevel_box), toolbox, FALSE, FALSE, 2);
1108 gtk_box_pack_start (GTK_BOX (toplevel_box), propbox, FALSE, FALSE, 2);
1109 gtk_box_pack_start (GTK_BOX (toplevel_box), seek_bar, FALSE, FALSE, 2);
1110 gtk_box_pack_start (GTK_BOX (toplevel_box), status_bar, FALSE, FALSE, 2);
1112 priv->window = window;
1113 priv->rate_entry = GTK_ENTRY (rate_entry);
1114 priv->status_bar = GTK_STATUSBAR (status_bar);
1115 priv->seek_range = GTK_RANGE (seek_range);
1116 priv->amount_played = GTK_LABEL (amount_played);
1117 priv->amount_to_play = GTK_LABEL (amount_to_play);
1118 priv->play_action = GTK_ACTION (play->action);
1119 priv->pause_action = GTK_ACTION (pause->action);
1120 priv->open_file = GTK_ACTION (open_file->action);
1121 priv->playlist_next = GTK_ACTION (playlist_next->action);
1123 gtk_action_set_sensitive (priv->pause_action, FALSE);
1124 gtk_action_set_visible (priv->pause_action, FALSE);
1126 gtk_widget_show_all (window);
1127 gtk_widget_grab_focus (seek_range);
1128 gtk_action_activate (priv->playlist_next);
1129 status_bar_printf (GTK_STATUSBAR (status_bar), 5,
1130 "Welcome to the Scaletempo demo.");
1132 if (!g_thread_create ((GThreadFunc) gtk_main, NULL, FALSE, &error)) {
1133 g_signal_emit (gui, demo_gui_signals[SIGNAL_ERROR], 0, error->message);
1138 /* Method wrappers */
1140 demo_gui_set_player (DemoGui * gui, DemoPlayer * player)
1142 g_return_if_fail (DEMO_IS_GUI (gui));
1143 g_return_if_fail (DEMO_IS_PLAYER (player));
1145 DEMO_GUI_GET_CLASS (gui)->set_player (gui, player);
1149 demo_gui_set_playlist (DemoGui * gui, GList * uris)
1151 g_return_if_fail (DEMO_IS_GUI (gui));
1153 DEMO_GUI_GET_CLASS (gui)->set_playlist (gui, uris);
1157 demo_gui_show (DemoGui * gui)
1159 g_return_if_fail (DEMO_IS_GUI (gui));
1161 DEMO_GUI_GET_CLASS (gui)->show (gui);
1166 /* GObject overrides */
1168 demo_gui_get_property (GObject * object,
1169 guint property_id, GValue * value, GParamSpec * pspec)
1171 //DemoGui *gui = DEMO_GUI (object);
1172 switch (property_id) {
1174 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1180 demo_gui_set_property (GObject * object,
1181 guint property_id, const GValue * value, GParamSpec * pspec)
1183 //DemoGui *gui = DEMO_GUI (object);
1184 switch (property_id) {
1186 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1192 /* GTypeInfo functions */
1194 demo_gui_init (GTypeInstance * instance, gpointer klass)
1196 DemoGui *gui = (DemoGui *) instance;
1198 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
1199 priv->player = NULL;
1201 priv->now_playing = NULL;
1202 priv->is_playing = FALSE;
1203 priv->window = NULL;
1204 priv->rate_entry = NULL;
1205 priv->position_updater_id = 0;
1206 priv->seek_range = NULL;
1207 priv->amount_played = NULL;
1208 priv->amount_to_play = NULL;
1212 demo_gui_class_init (gpointer klass, gpointer class_data)
1214 DemoGuiClass *gui_class = (DemoGuiClass *) klass;
1215 GObjectClass *as_object_class = G_OBJECT_CLASS (klass);
1218 g_type_class_add_private (klass, sizeof (DemoGuiPrivate));
1221 gui_class->set_player = demo_gui_set_player_func;
1222 gui_class->set_playlist = demo_gui_set_playlist_func;
1223 gui_class->show = demo_gui_show_func;
1226 as_object_class->get_property = demo_gui_get_property;
1227 as_object_class->set_property = demo_gui_set_property;
1232 type = G_TYPE_FROM_CLASS (klass);
1233 demo_gui_signals[SIGNAL_ERROR] = g_signal_new ("error", type,
1234 G_SIGNAL_RUN_FIRST, 0, NULL, NULL,
1235 g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
1237 demo_gui_signals[SIGNAL_QUITING] = g_signal_new ("quiting", type,
1238 G_SIGNAL_RUN_FIRST, 0, NULL, NULL,
1239 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL);
1243 demo_gui_get_type (void)
1245 static GType type = 0;
1246 if (G_UNLIKELY (type == 0)) {
1247 static const GTypeInfo info = {
1248 sizeof /* Class */ (DemoGuiClass),
1249 (GBaseInitFunc) NULL,
1250 (GBaseFinalizeFunc) NULL,
1251 (GClassInitFunc) demo_gui_class_init,
1252 (GClassFinalizeFunc) NULL,
1253 (gconstpointer) NULL, /* class_data */
1254 sizeof /* Instance */ (DemoGui),
1255 /* n_preallocs */ 0,
1256 (GInstanceInitFunc) demo_gui_init,
1257 (const GTypeValueTable *) NULL
1259 type = g_type_register_static (G_TYPE_OBJECT, "DemoGui", &info, 0);