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/>.
22 #include <gst/glib-compat-private.h>
24 #include <glib/gprintf.h>
29 #define G_LOG_DOMAIN "demo-gui"
37 static guint demo_gui_signals[LAST_SIGNAL] = { 0 };
44 typedef struct _DemoGuiPrivate
52 GtkStatusbar *status_bar;
53 gint position_updater_id;
55 GtkLabel *amount_played;
56 GtkLabel *amount_to_play;
57 GtkAction *play_action;
58 GtkAction *pause_action;
60 GtkAction *playlist_next;
63 #define DEMO_GUI_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEMO_TYPE_GUI, DemoGuiPrivate))
65 /* forward declarations */
66 static GValueArray *build_gvalue_array (guint n_values, ...);
68 /* Handlers for status bar and seek bar */
70 pop_status_bar (gpointer data)
72 GValueArray *gvalues = (GValueArray *) data;
74 GTK_STATUSBAR (g_value_get_object (g_value_array_get_nth (gvalues, 0)));
75 guint msg_id = g_value_get_uint (g_value_array_get_nth (gvalues, 1));
77 gtk_statusbar_remove (sb, 0, msg_id);
81 #define DEFAULT_STATUS_BAR_TIMEOUT 2
83 status_bar_printf (GtkStatusbar * sb, guint seconds, gchar const *format, ...)
89 va_start (args, format);
90 g_vsnprintf (msg, 80, format, args);
93 msg_id = gtk_statusbar_push (sb, 0, msg);
94 g_timeout_add (2000, pop_status_bar,
95 build_gvalue_array (2, G_TYPE_OBJECT, sb, G_TYPE_UINT, msg_id));
98 #define PRINTF_TIME_FORMAT "u:%02u:%02u"
99 #define PRINTF_TIME_ARGS(t) \
100 (t >= 0) ? (guint) ((t) / (60 * 60)) : 99, \
101 (t >= 0) ? (guint) (((t) / (60)) % 60) : 99, \
102 (t >= 0) ? (guint) ((t) % 60) : 99
105 demo_gui_seek_bar_format (GtkScale * scale, gdouble value, gpointer data)
107 return g_strdup_printf ("%" PRINTF_TIME_FORMAT,
108 PRINTF_TIME_ARGS ((gint64) value));
112 update_position (gpointer data)
114 DemoGui *gui = DEMO_GUI (data);
115 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
116 gchar pos_str[16], dur_str[16];
117 gint pos = demo_player_get_position (priv->player);
120 gint dur = demo_player_get_duration (priv->player);
122 g_snprintf (pos_str, 16, "%" PRINTF_TIME_FORMAT, PRINTF_TIME_ARGS (pos));
124 g_snprintf (dur_str, 16, "-%" PRINTF_TIME_FORMAT,
125 PRINTF_TIME_ARGS (dur - pos));
128 g_sprintf (dur_str, "-??:??:??");
131 gtk_range_set_range (GTK_RANGE (priv->seek_range), 0, (gdouble) dur);
132 gtk_range_set_value (GTK_RANGE (priv->seek_range), (gdouble) pos);
134 g_sprintf (pos_str, "??:??:??");
135 g_sprintf (dur_str, "-??:??:??");
137 gtk_label_set_text (GTK_LABEL (priv->amount_played), pos_str);
138 gtk_label_set_text (GTK_LABEL (priv->amount_to_play), dur_str);
140 return priv->is_playing;
145 demo_gui_seek_bar_change (GtkRange * range,
146 GtkScrollType scroll, gdouble value, gpointer data)
148 DemoGui *gui = DEMO_GUI (data);
149 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
150 gint new_second = (gint) value;
152 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
153 "Seeking to %i second", new_second);
154 demo_player_seek_to (priv->player, new_second);
160 /* Callbacks for actions */
162 demo_gui_do_change_rate (GtkAction * action, gpointer data)
164 GValueArray *gvalues = (GValueArray *) data;
165 DemoGui *gui = g_value_get_object (g_value_array_get_nth (gvalues, 0));
166 gdouble scale_amount =
167 g_value_get_double (g_value_array_get_nth (gvalues, 1));
168 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
170 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
171 "Changing rate by %3.2lf", scale_amount);
173 demo_player_scale_rate (priv->player, scale_amount);
177 demo_gui_do_set_rate (GtkAction * action, gpointer data)
179 GValueArray *gvalues = (GValueArray *) data;
180 DemoGui *gui = g_value_get_object (g_value_array_get_nth (gvalues, 0));
181 gdouble new_rate = g_value_get_double (g_value_array_get_nth (gvalues, 1));
182 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
184 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
185 "Setting rate to %3.2lf", new_rate);
187 demo_player_set_rate (priv->player, new_rate);
191 demo_gui_do_rate_entered (GtkWidget * widget, gpointer data)
193 DemoGui *gui = DEMO_GUI (data);
194 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
196 const gchar *text = gtk_entry_get_text (GTK_ENTRY (widget));
197 double new_rate = g_strtod (text, &err);
200 gtk_widget_error_bell (priv->window);
201 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
202 "Invalid rate: %s", text);
206 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
207 "Setting rate to %3.2lf", new_rate);
209 demo_player_set_rate (priv->player, new_rate);
214 demo_gui_do_toggle_advanced (GtkAction * action, gpointer data)
216 GValueArray *gvalues = (GValueArray *) data;
218 DEMO_GUI (g_value_get_object (g_value_array_get_nth (gvalues, 0)));
219 GtkWidget *stride_ui =
220 GTK_WIDGET (g_value_get_object (g_value_array_get_nth (gvalues, 1)));
221 GtkWidget *overlap_ui =
222 GTK_WIDGET (g_value_get_object (g_value_array_get_nth (gvalues, 2)));
223 GtkWidget *search_ui =
224 GTK_WIDGET (g_value_get_object (g_value_array_get_nth (gvalues, 3)));
225 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
228 status_bar_printf (priv->status_bar, 1, "Toggling advanced mode");
230 active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
231 gtk_widget_set_sensitive (stride_ui, active);
232 gtk_widget_set_sensitive (overlap_ui, active);
233 gtk_widget_set_sensitive (search_ui, active);
237 demo_gui_do_toggle_disabled (GtkAction * action, gpointer data)
239 GValueArray *gvalues = (GValueArray *) data;
241 DEMO_GUI (g_value_get_object (g_value_array_get_nth (gvalues, 0)));
242 GtkAction *advanced_action =
243 GTK_ACTION (g_value_get_object (g_value_array_get_nth (gvalues, 1)));
244 GtkWidget *advanced_ui =
245 GTK_WIDGET (g_value_get_object (g_value_array_get_nth (gvalues, 2)));
247 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
250 status_bar_printf (priv->status_bar, 1, "Toggling disabled");
252 active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
253 gtk_action_set_sensitive (GTK_ACTION (advanced_action), !active);
254 gtk_widget_set_sensitive (GTK_WIDGET (advanced_ui), !active);
255 g_object_set (G_OBJECT (priv->player), "disabled", active, NULL);
259 demo_gui_do_seek (GtkAction * action, gpointer data)
261 GValueArray *gvalues = (GValueArray *) data;
263 DEMO_GUI (g_value_get_object (g_value_array_get_nth (gvalues, 0)));
264 gint seconds = g_value_get_int (g_value_array_get_nth (gvalues, 1));
265 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
267 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
268 "Requesting seek by %i seconds", seconds);
270 demo_player_seek_by (priv->player, seconds);
274 demo_gui_do_play (GtkAction * action, gpointer data)
276 DemoGui *gui = DEMO_GUI (data);
277 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
279 if (priv->is_playing) {
280 g_signal_emit (gui, demo_gui_signals[SIGNAL_ERROR], 0, "Already playing");
284 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
285 "Requesting playback start");
287 demo_player_play (priv->player);
291 demo_gui_do_pause (GtkAction * action, gpointer data)
293 DemoGui *gui = DEMO_GUI (data);
294 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
296 if (!priv->is_playing) {
297 g_signal_emit (gui, demo_gui_signals[SIGNAL_ERROR], 0, "Already paused");
301 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
302 "Requesting playback pause");
304 demo_player_pause (priv->player);
308 demo_gui_do_play_pause (GtkAction * action, gpointer data)
310 DemoGui *gui = DEMO_GUI (data);
311 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
313 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
314 "Reqesting playback toggle");
316 if (priv->is_playing)
317 gtk_action_activate (priv->pause_action);
319 gtk_action_activate (priv->play_action);
323 demo_gui_do_open_file (GtkAction * action, gpointer data)
325 DemoGui *gui = DEMO_GUI (data);
326 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
327 GtkWidget *dialog = gtk_file_chooser_dialog_new ("Open File",
328 GTK_WINDOW (priv->window),
329 GTK_FILE_CHOOSER_ACTION_OPEN,
330 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
331 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
334 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
335 char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
338 g_list_free (priv->uris);
340 priv->now_playing = NULL;
341 demo_player_load_uri (priv->player, g_filename_to_uri (filename, NULL,
345 gtk_widget_destroy (dialog);
349 demo_gui_do_playlist_prev (GtkAction * action, gpointer data)
351 DemoGui *gui = DEMO_GUI (data);
352 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
354 if (priv->now_playing) {
355 if (priv->now_playing->prev) {
356 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
357 "Playlist previous");
358 priv->now_playing = priv->now_playing->prev;
360 priv->now_playing = NULL;
361 gtk_widget_error_bell (priv->window);
362 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
363 "Beginning of playlist");
366 } else if (priv->uris) {
367 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
368 "Playlist previous: wrap");
369 priv->now_playing = g_list_last (priv->uris);
371 gtk_action_activate (priv->open_file);
375 demo_player_load_uri (priv->player, priv->now_playing->data);
379 demo_gui_do_playlist_next (GtkAction * action, gpointer data)
381 DemoGui *gui = DEMO_GUI (data);
382 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
384 if (priv->now_playing) {
385 if (priv->now_playing->next) {
386 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
388 priv->now_playing = priv->now_playing->next;
390 priv->now_playing = NULL;
391 gtk_widget_error_bell (priv->window);
392 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
396 } else if (priv->uris) {
397 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
398 "Playlist next: wrap");
399 priv->now_playing = priv->uris;
401 gtk_action_activate (priv->open_file);
405 demo_player_load_uri (priv->player, priv->now_playing->data);
409 demo_gui_do_about_dialog (GtkAction * action, gpointer data)
411 static const gchar *authors[] =
412 { "Rov Juvano <rovjuvano@users.sourceforge.net>", NULL };
414 gtk_show_about_dialog (NULL,
415 "program-name", "gst-scaletempo-demo",
418 "license", "This program is free software: you can redistribute it and/or modify\n\
419 it under the terms of the GNU General Public License as published by\n\
420 the Free Software Foundation, either version 3 of the License, or\n\
421 (at your option) any later version.\n\
423 This program is distributed in the hope that it will be useful,\n\
424 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
425 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
426 GNU General Public License for more details.\n\
428 You should have received a copy of the GNU General Public License\n\
429 along with this program. If not, see <http://www.gnu.org/licenses/>.", "title", "About gst-scaletempo-demo", NULL);
433 demo_gui_do_quit (gpointer source, gpointer data)
436 g_signal_emit (DEMO_GUI (data), demo_gui_signals[SIGNAL_QUITING], 0, NULL);
440 demo_gui_request_set_stride (GtkSpinButton * spinbutton, gpointer data)
442 DemoGui *gui = DEMO_GUI (data);
443 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
444 guint new_stride = gtk_spin_button_get_value_as_int (spinbutton);
446 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
447 "Reqesting setting stride to %u ms", new_stride);
448 g_object_set (G_OBJECT (priv->player), "stride", new_stride, NULL);
453 demo_gui_request_set_overlap (GtkSpinButton * spinbutton, gpointer data)
455 DemoGui *gui = DEMO_GUI (data);
456 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
457 gdouble new_overlap = gtk_spin_button_get_value_as_int (spinbutton);
459 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
460 "Requesting setting overlap to %2.0lf%%", new_overlap);
461 g_object_set (G_OBJECT (priv->player), "overlap", new_overlap / 100.0, NULL);
466 demo_gui_request_set_search (GtkSpinButton * spinbutton, gpointer data)
468 DemoGui *gui = DEMO_GUI (data);
469 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
470 guint new_search = gtk_spin_button_get_value_as_int (spinbutton);
472 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
473 "Requesting setting search to %u ms", new_search);
474 g_object_set (G_OBJECT (priv->player), "search", new_search, NULL);
479 /* Callbacks from signals */
481 demo_gui_rate_changed (DemoPlayer * player, gdouble new_rate, gpointer data)
483 DemoGui *gui = DEMO_GUI (data);
484 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
487 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
488 "Rate changed to %3.2lf", new_rate);
490 g_snprintf (e, 6, "%3.2f", new_rate);
491 gtk_entry_set_text (GTK_ENTRY (priv->rate_entry), e);
495 demo_gui_playing_started (DemoPlayer * player, gpointer data)
497 DemoGui *gui = DEMO_GUI (data);
498 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
500 priv->is_playing = TRUE;
501 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
504 gtk_action_set_sensitive (priv->play_action, FALSE);
505 gtk_action_set_sensitive (priv->pause_action, TRUE);
506 gtk_action_set_visible (priv->play_action, FALSE);
507 gtk_action_set_visible (priv->pause_action, TRUE);
509 if (priv->position_updater_id) {
510 g_source_remove (priv->position_updater_id);
511 priv->position_updater_id = 0;
513 update_position (gui);
514 priv->position_updater_id = g_timeout_add (1000, update_position, gui);
518 demo_gui_playing_paused (DemoPlayer * player, gpointer data)
520 DemoGui *gui = DEMO_GUI (data);
521 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
523 gtk_action_set_sensitive (priv->play_action, TRUE);
524 gtk_action_set_sensitive (priv->pause_action, FALSE);
525 gtk_action_set_visible (priv->play_action, TRUE);
526 gtk_action_set_visible (priv->pause_action, FALSE);
528 priv->is_playing = FALSE;
530 if (priv->position_updater_id)
531 g_source_remove (priv->position_updater_id);
532 priv->position_updater_id = 0;
533 update_position (gui);
535 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
540 demo_gui_playing_ended (DemoPlayer * player, gpointer data)
542 DemoGui *gui = DEMO_GUI (data);
543 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
545 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
547 gtk_action_activate (priv->playlist_next);
551 demo_gui_player_errored (DemoPlayer * player, const gchar * msg, gpointer data)
553 DemoGui *gui = DEMO_GUI (data);
554 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
556 status_bar_printf (priv->status_bar, 5, msg);
560 demo_gui_stride_changed (DemoPlayer * player, GParamSpec * pspec, gpointer data)
562 GValueArray *gvalues = (GValueArray *) data;
564 DEMO_GUI (g_value_get_object (g_value_array_get_nth (gvalues, 0)));
566 GTK_ENTRY (g_value_get_object (g_value_array_get_nth (gvalues, 1)));
567 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
571 g_object_get (G_OBJECT (player), "stride", &new_stride, NULL);
572 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
573 "Stride changed to %u", new_stride);
575 snprintf (e, 6, "%u", new_stride);
576 gtk_entry_set_text (entry, e);
580 demo_gui_overlap_changed (DemoPlayer * player,
581 GParamSpec * pspec, gpointer data)
583 GValueArray *gvalues = (GValueArray *) data;
585 DEMO_GUI (g_value_get_object (g_value_array_get_nth (gvalues, 0)));
587 GTK_ENTRY (g_value_get_object (g_value_array_get_nth (gvalues, 1)));
588 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
592 g_object_get (G_OBJECT (player), "overlap", &new_overlap, NULL);
594 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
595 "Overlap changed to %2.0lf%%", new_overlap);
597 snprintf (e, 6, "%2.0f", new_overlap);
598 gtk_entry_set_text (entry, e);
602 demo_gui_search_changed (DemoPlayer * player, GParamSpec * pspec, gpointer data)
604 GValueArray *gvalues = (GValueArray *) data;
606 DEMO_GUI (g_value_get_object (g_value_array_get_nth (gvalues, 0)));
608 GTK_ENTRY (g_value_get_object (g_value_array_get_nth (gvalues, 1)));
609 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
613 g_object_get (G_OBJECT (player), "search", &new_search, NULL);
614 status_bar_printf (priv->status_bar, DEFAULT_STATUS_BAR_TIMEOUT,
615 "Search changed to %u", new_search);
617 snprintf (e, 6, "%u", new_search);
618 gtk_entry_set_text (entry, e);
622 /* method implementations */
624 demo_gui_set_player_func (DemoGui * gui, DemoPlayer * player)
626 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
629 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->player),
630 G_CALLBACK (demo_gui_rate_changed), gui);
631 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->player),
632 G_CALLBACK (demo_gui_playing_started), gui);
633 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->player),
634 G_CALLBACK (demo_gui_playing_paused), gui);
635 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->player),
636 G_CALLBACK (demo_gui_playing_ended), gui);
637 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->player),
638 G_CALLBACK (demo_gui_player_errored), gui);
639 g_object_unref (priv->player);
641 g_object_ref (player);
642 priv->player = player;
643 g_signal_connect (G_OBJECT (priv->player), "error",
644 G_CALLBACK (demo_gui_player_errored), gui);
645 g_signal_connect (G_OBJECT (priv->player), "rate-changed",
646 G_CALLBACK (demo_gui_rate_changed), gui);
647 g_signal_connect (G_OBJECT (priv->player), "playing-started",
648 G_CALLBACK (demo_gui_playing_started), gui);
649 g_signal_connect (G_OBJECT (priv->player), "playing-paused",
650 G_CALLBACK (demo_gui_playing_paused), gui);
651 g_signal_connect (G_OBJECT (priv->player), "playing-ended",
652 G_CALLBACK (demo_gui_playing_ended), gui);
653 priv->is_playing = FALSE;
657 demo_gui_set_playlist_func (DemoGui * gui, GList * uris)
659 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
663 typedef struct _ActionEntry
670 const gchar *tooltip;
671 const gchar *stock_id;
672 GtkAccelGroup *accel_group;
673 GtkActionGroup *action_group;
679 build_gvalue_array (guint n_values, ...)
685 va_start (args, n_values);
686 gva = g_value_array_new (n_values);
688 for (i = 0; i < n_values; i++) {
689 GType type = va_arg (args, GType);
690 GValue *gval = g_new0 (GValue, 1);
691 if (type == G_TYPE_INT) {
692 gint value = va_arg (args, gint);
693 g_value_set_int (g_value_init (gval, G_TYPE_INT), value);
694 } else if (type == G_TYPE_UINT) {
695 guint value = va_arg (args, guint);
696 g_value_set_uint (g_value_init (gval, G_TYPE_UINT), value);
697 } else if (type == G_TYPE_DOUBLE) {
698 double value = va_arg (args, double);
699 g_value_set_double (g_value_init (gval, G_TYPE_DOUBLE), value);
700 } else if (type == G_TYPE_OBJECT) {
701 GObject *value = va_arg (args, GObject *);
702 g_value_set_object (g_value_init (gval, G_TYPE_OBJECT), value);
704 g_critical ("build_gvalue_array cannot handle type (%s)",
709 g_value_array_append (gva, gval);
716 create_action (ActionEntry * p)
718 p->action = gtk_action_new (p->name, p->label, p->tooltip, p->stock_id);
720 gtk_action_group_add_action_with_accel (p->action_group, p->action, p->accel);
721 gtk_action_set_accel_group (p->action, p->accel_group);
722 gtk_action_connect_accelerator (p->action);
724 p->button = gtk_button_new ();
725 #if GTK_CHECK_VERSION (2, 16, 0)
726 gtk_activatable_set_related_action (GTK_ACTIVATABLE (p->button), p->action);
728 gtk_action_connect_proxy (p->action, p->button);
730 gtk_button_set_image (GTK_BUTTON (p->button),
731 gtk_action_create_icon (p->action, GTK_ICON_SIZE_BUTTON));
732 g_signal_connect (G_OBJECT (p->action), "activate", p->callback, p->data);
736 demo_gui_show_func (DemoGui * gui)
738 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
740 GtkAccelGroup *accel_group;
741 GtkActionGroup *action_group;
742 GtkAction *toggle_advanced, *toggle_disabled;
743 ActionEntry *slower_lg, *slower_sm, *faster_sm, *faster_lg, *normal,
744 *rewind_lg, *rewind_sm, *forward_sm, *forward_lg, *pause, *play,
745 *play_pause, *open_file, *playlist_prev, *playlist_next, *quit, *about;
746 GtkRequisition pause_size;
747 GtkWidget *rate_entry, *rate_label, *toolbox, *stride_ui, *overlap_ui,
748 *search_ui, *propbox, *adv_check, *disabled_check, *media_controls,
749 *amount_played, *amount_to_play, *seek_range, *seek_bar, *status_bar,
750 *file_menu, *file_menu_item, *media_menu_item, *demo_menu,
751 *demo_menu_item, *menu_bar, *toplevel_box, *media_menu;
752 GError *error = NULL;
754 gtk_init (NULL, NULL);
755 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
756 g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (demo_gui_do_quit),
759 accel_group = gtk_accel_group_new ();
760 gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
761 action_group = gtk_action_group_new ("toolbar");
763 slower_lg = &(ActionEntry) {
765 "braceleft", "slower-large",
766 "2x Slower", "half playback rate",
767 GTK_STOCK_GO_DOWN, accel_group, action_group,
768 G_CALLBACK (demo_gui_do_change_rate),
769 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_DOUBLE, 0.5)
771 create_action (slower_lg);
773 slower_sm = &(ActionEntry) {
775 "bracketleft", "slower-small",
776 "_Slower", "decrease playback rate",
777 GTK_STOCK_GO_DOWN, accel_group, action_group,
778 G_CALLBACK (demo_gui_do_change_rate),
779 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_DOUBLE, pow (2,
782 create_action (slower_sm);
784 faster_sm = &(ActionEntry) {
786 "bracketright", "faster-small",
787 "_Faster", "increase playback rate",
788 GTK_STOCK_GO_UP, accel_group, action_group,
789 G_CALLBACK (demo_gui_do_change_rate),
790 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_DOUBLE, pow (2,
793 create_action (faster_sm);
795 faster_lg = &(ActionEntry) {
797 "braceright", "faster-large",
798 "2X Faster", "double playback rate",
799 GTK_STOCK_GO_UP, accel_group, action_group,
800 G_CALLBACK (demo_gui_do_change_rate),
801 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_DOUBLE, 2.0)
803 create_action (faster_lg);
805 normal = &(ActionEntry) {
807 "backslash", "normal",
808 "_Normal", "playback normal rate",
809 GTK_STOCK_CLEAR, accel_group, action_group,
810 G_CALLBACK (demo_gui_do_set_rate),
811 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_DOUBLE, 1.0)
813 create_action (normal);
815 rewind_lg = &(ActionEntry) {
817 "<ctrl><shift>Left", "seek-rewind-large",
818 "Rewind (large)", "seek -30 seconds",
819 GTK_STOCK_MEDIA_REWIND, accel_group, action_group,
820 G_CALLBACK (demo_gui_do_seek),
821 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_INT, -30)
823 create_action (rewind_lg);
825 rewind_sm = &(ActionEntry) {
827 "<ctrl>Left", "seek-rewind-small",
828 "Rewind", "seek -15 seconds",
829 GTK_STOCK_MEDIA_REWIND, accel_group, action_group,
830 G_CALLBACK (demo_gui_do_seek),
831 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_INT, -5)
833 create_action (rewind_sm);
835 forward_sm = &(ActionEntry) {
837 "<ctrl>Right", "seek-forward-small",
838 "Forward", "seek +5 seconds",
839 GTK_STOCK_MEDIA_FORWARD, accel_group, action_group,
840 G_CALLBACK (demo_gui_do_seek),
841 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_INT, 5)
843 create_action (forward_sm);
845 forward_lg = &(ActionEntry) {
847 "<ctrl><shift>Right", "seek-forward-large",
848 "Forward (large)", "seek +30 seconds",
849 GTK_STOCK_MEDIA_FORWARD, accel_group, action_group,
850 G_CALLBACK (demo_gui_do_seek),
851 build_gvalue_array (2, G_TYPE_OBJECT, gui, G_TYPE_INT, 30)
853 create_action (forward_lg);
855 pause = &(ActionEntry) {
858 "Pause", "Pause playback",
859 GTK_STOCK_MEDIA_PAUSE, accel_group, action_group,
860 G_CALLBACK (demo_gui_do_pause), gui};
861 create_action (pause);
863 play = &(ActionEntry) {
866 "Play", "Start Playback",
867 GTK_STOCK_MEDIA_PLAY, accel_group, action_group,
868 G_CALLBACK (demo_gui_do_play), gui};
869 create_action (play);
870 gtk_widget_size_request (pause->button, &pause_size);
871 gtk_widget_set_size_request (play->button, pause_size.width, -1);
873 play_pause = &(ActionEntry) {
875 "space", "play-pause",
876 "Play/Pause", "Toggle playback",
877 NULL, accel_group, action_group,
878 G_CALLBACK (demo_gui_do_play_pause), gui};
879 create_action (play_pause);
881 open_file = &(ActionEntry) {
883 "<ctrl>o", "open-file",
884 "Open File", "Open file for playing",
885 GTK_STOCK_OPEN, accel_group, action_group,
886 G_CALLBACK (demo_gui_do_open_file), gui};
887 create_action (open_file);
889 playlist_prev = &(ActionEntry) {
891 "less", "playlist-previous",
892 "Previous", "Previous in playlist",
893 GTK_STOCK_MEDIA_PREVIOUS, accel_group, action_group,
894 G_CALLBACK (demo_gui_do_playlist_prev), gui};
895 create_action (playlist_prev);
897 playlist_next = &(ActionEntry) {
899 "greater", "playlist-next",
900 "Next", "Next in playlist",
901 GTK_STOCK_MEDIA_NEXT, accel_group, action_group,
902 G_CALLBACK (demo_gui_do_playlist_next), gui};
903 create_action (playlist_next);
905 quit = &(ActionEntry) {
909 GTK_STOCK_QUIT, accel_group, action_group,
910 G_CALLBACK (demo_gui_do_quit), gui};
911 create_action (quit);
913 about = &(ActionEntry) {
916 "About", "About gst-scaletemo-demo",
917 GTK_STOCK_ABOUT, accel_group, action_group,
918 G_CALLBACK (demo_gui_do_about_dialog), gui};
919 create_action (about);
921 rate_entry = gtk_entry_new ();
922 rate_label = gtk_label_new ("Rate:");
923 gtk_entry_set_max_length (GTK_ENTRY (rate_entry), 5);
924 gtk_entry_set_text (GTK_ENTRY (rate_entry), "1.0");
925 gtk_entry_set_width_chars (GTK_ENTRY (rate_entry), 5);
926 g_signal_connect (G_OBJECT (rate_entry), "activate",
927 G_CALLBACK (demo_gui_do_rate_entered), gui);
929 toolbox = gtk_hbox_new (FALSE, 0);
930 gtk_box_pack_start (GTK_BOX (toolbox), slower_sm->button, FALSE, FALSE, 2);
931 gtk_box_pack_start (GTK_BOX (toolbox), rate_label, FALSE, FALSE, 2);
932 gtk_box_pack_start (GTK_BOX (toolbox), rate_entry, FALSE, FALSE, 2);
933 gtk_box_pack_start (GTK_BOX (toolbox), faster_sm->button, FALSE, FALSE, 2);
934 gtk_box_pack_start (GTK_BOX (toolbox), normal->button, FALSE, FALSE, 2);
938 gtk_spin_button_new (GTK_ADJUSTMENT (gtk_adjustment_new (60, 1, 1000, 1,
941 gtk_spin_button_new (GTK_ADJUSTMENT (gtk_adjustment_new (20, 0, 100, 5,
944 gtk_spin_button_new (GTK_ADJUSTMENT (gtk_adjustment_new (14, 0, 1000, 1,
946 gtk_widget_set_sensitive (stride_ui, FALSE);
947 gtk_widget_set_sensitive (overlap_ui, FALSE);
948 gtk_widget_set_sensitive (search_ui, FALSE);
949 g_signal_connect (G_OBJECT (stride_ui), "output",
950 G_CALLBACK (demo_gui_request_set_stride), gui);
951 g_signal_connect (G_OBJECT (overlap_ui), "output",
952 G_CALLBACK (demo_gui_request_set_overlap), gui);
953 g_signal_connect (G_OBJECT (search_ui), "output",
954 G_CALLBACK (demo_gui_request_set_search), gui);
955 g_signal_connect (G_OBJECT (priv->player), "notify::stride",
956 G_CALLBACK (demo_gui_stride_changed), build_gvalue_array (2,
957 G_TYPE_OBJECT, gui, G_TYPE_OBJECT, stride_ui));
958 g_signal_connect (G_OBJECT (priv->player), "notify::overlap",
959 G_CALLBACK (demo_gui_overlap_changed), build_gvalue_array (2,
960 G_TYPE_OBJECT, gui, G_TYPE_OBJECT, overlap_ui));
961 g_signal_connect (G_OBJECT (priv->player), "notify::search",
962 G_CALLBACK (demo_gui_search_changed), build_gvalue_array (2,
963 G_TYPE_OBJECT, gui, G_TYPE_OBJECT, search_ui));
964 propbox = gtk_hbox_new (FALSE, 0);
965 adv_check = gtk_check_button_new ();
966 gtk_box_pack_start (GTK_BOX (propbox), gtk_label_new ("stride:"), FALSE,
968 gtk_box_pack_start (GTK_BOX (propbox), stride_ui, FALSE, FALSE, 2);
969 gtk_box_pack_start (GTK_BOX (propbox), gtk_label_new ("overlap:"), FALSE,
971 gtk_box_pack_start (GTK_BOX (propbox), overlap_ui, FALSE, FALSE, 2);
972 gtk_box_pack_start (GTK_BOX (propbox), gtk_label_new ("search:"), FALSE,
974 gtk_box_pack_start (GTK_BOX (propbox), search_ui, FALSE, FALSE, 2);
975 gtk_box_pack_start (GTK_BOX (propbox), adv_check, FALSE, FALSE, 2);
978 GTK_ACTION (gtk_toggle_action_new ("advanced", "Enable Parameters",
979 "Toggle advanced controls", 0));
980 gtk_action_group_add_action_with_accel (action_group, toggle_advanced,
982 gtk_action_set_accel_group (toggle_advanced, accel_group);
983 gtk_action_connect_accelerator (toggle_advanced);
984 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (toggle_advanced), FALSE);
985 #if GTK_CHECK_VERSION (2, 16, 0)
986 gtk_activatable_set_related_action (GTK_ACTIVATABLE (adv_check),
989 gtk_action_connect_proxy (toggle_advanced, adv_check);
991 g_signal_connect (G_OBJECT (toggle_advanced), "activate",
992 G_CALLBACK (demo_gui_do_toggle_advanced), build_gvalue_array (4,
993 G_TYPE_OBJECT, gui, G_TYPE_OBJECT, stride_ui, G_TYPE_OBJECT,
994 overlap_ui, G_TYPE_OBJECT, search_ui));
997 GTK_ACTION (gtk_toggle_action_new ("disabled", "Disable Scaletempo",
998 "Toggle disabling scaletempo", 0));
999 gtk_action_group_add_action_with_accel (action_group, toggle_disabled,
1001 gtk_action_set_accel_group (toggle_disabled, accel_group);
1002 gtk_action_connect_accelerator (toggle_disabled);
1003 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (toggle_disabled), FALSE);
1004 disabled_check = gtk_check_button_new ();
1005 #if GTK_CHECK_VERSION (2, 16, 0)
1006 gtk_activatable_set_related_action (GTK_ACTIVATABLE (disabled_check),
1009 gtk_action_connect_proxy (toggle_disabled, disabled_check);
1011 g_signal_connect (G_OBJECT (toggle_disabled), "activate",
1012 G_CALLBACK (demo_gui_do_toggle_disabled), build_gvalue_array (3,
1013 G_TYPE_OBJECT, gui, G_TYPE_OBJECT, toggle_advanced, G_TYPE_OBJECT,
1015 gtk_box_pack_start (GTK_BOX (toolbox), disabled_check, FALSE, FALSE, 2);
1018 media_controls = gtk_hbox_new (FALSE, 0);
1019 gtk_box_pack_start (GTK_BOX (media_controls), playlist_prev->button, FALSE,
1021 gtk_box_pack_start (GTK_BOX (media_controls), rewind_sm->button, FALSE, FALSE,
1023 gtk_box_pack_start (GTK_BOX (media_controls), play->button, FALSE, FALSE, 2);
1024 gtk_box_pack_start (GTK_BOX (media_controls), pause->button, FALSE, FALSE, 2);
1025 gtk_box_pack_start (GTK_BOX (media_controls), forward_sm->button, FALSE,
1027 gtk_box_pack_start (GTK_BOX (media_controls), playlist_next->button, FALSE,
1030 amount_played = gtk_label_new ("?:??:??");
1031 amount_to_play = gtk_label_new ("-?:??:??");
1032 gtk_label_set_width_chars (GTK_LABEL (amount_played), 8);
1033 gtk_label_set_width_chars (GTK_LABEL (amount_to_play), 8);
1034 gtk_misc_set_alignment (GTK_MISC (amount_played), 1, 1);
1035 gtk_misc_set_alignment (GTK_MISC (amount_to_play), 0, 1);
1037 gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 5.0,
1039 #if !GTK_CHECK_VERSION (3, 0, 0)
1040 gtk_range_set_update_policy (GTK_RANGE (seek_range),
1041 GTK_UPDATE_DISCONTINUOUS);
1043 seek_bar = gtk_hbox_new (FALSE, 0);
1044 gtk_box_pack_start (GTK_BOX (seek_bar), amount_played, FALSE, FALSE, 2);
1045 gtk_box_pack_start (GTK_BOX (seek_bar), seek_range, TRUE, TRUE, 2);
1046 gtk_box_pack_start (GTK_BOX (seek_bar), amount_to_play, FALSE, FALSE, 2);
1047 g_signal_connect (G_OBJECT (seek_range), "format-value",
1048 G_CALLBACK (demo_gui_seek_bar_format), gui);
1049 g_signal_connect (G_OBJECT (seek_range), "change-value",
1050 G_CALLBACK (demo_gui_seek_bar_change), gui);
1052 status_bar = gtk_statusbar_new ();
1055 file_menu = gtk_menu_new ();
1056 gtk_menu_set_accel_group (GTK_MENU (file_menu), accel_group);
1057 gtk_menu_shell_append (GTK_MENU_SHELL (file_menu),
1058 gtk_action_create_menu_item (open_file->action));
1059 gtk_menu_shell_append (GTK_MENU_SHELL (file_menu),
1060 gtk_action_create_menu_item (about->action));
1061 gtk_menu_shell_append (GTK_MENU_SHELL (file_menu),
1062 gtk_action_create_menu_item (quit->action));
1063 file_menu_item = gtk_menu_item_new_with_mnemonic ("_File");
1064 gtk_menu_item_set_submenu (GTK_MENU_ITEM (file_menu_item), file_menu);
1066 media_menu = gtk_menu_new ();
1067 gtk_menu_set_accel_group (GTK_MENU (media_menu), accel_group);
1068 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1069 gtk_action_create_menu_item (rewind_lg->action));
1070 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1071 gtk_action_create_menu_item (rewind_sm->action));
1072 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1073 gtk_action_create_menu_item (forward_sm->action));
1074 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1075 gtk_action_create_menu_item (forward_lg->action));
1076 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1077 gtk_action_create_menu_item (play->action));
1078 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1079 gtk_action_create_menu_item (pause->action));
1080 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1081 gtk_action_create_menu_item (play_pause->action));
1082 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1083 gtk_action_create_menu_item (playlist_prev->action));
1084 gtk_menu_shell_append (GTK_MENU_SHELL (media_menu),
1085 gtk_action_create_menu_item (playlist_next->action));
1086 media_menu_item = gtk_menu_item_new_with_mnemonic ("_Media");
1087 gtk_menu_item_set_submenu (GTK_MENU_ITEM (media_menu_item), media_menu);
1089 demo_menu = gtk_menu_new ();
1090 gtk_menu_set_accel_group (GTK_MENU (demo_menu), accel_group);
1091 gtk_menu_shell_append (GTK_MENU_SHELL (demo_menu),
1092 gtk_action_create_menu_item (faster_lg->action));
1093 gtk_menu_shell_append (GTK_MENU_SHELL (demo_menu),
1094 gtk_action_create_menu_item (faster_sm->action));
1095 gtk_menu_shell_append (GTK_MENU_SHELL (demo_menu),
1096 gtk_action_create_menu_item (slower_sm->action));
1097 gtk_menu_shell_append (GTK_MENU_SHELL (demo_menu),
1098 gtk_action_create_menu_item (slower_lg->action));
1099 gtk_menu_shell_append (GTK_MENU_SHELL (demo_menu),
1100 gtk_action_create_menu_item (normal->action));
1101 gtk_menu_shell_append (GTK_MENU_SHELL (demo_menu),
1102 gtk_action_create_menu_item (toggle_disabled));
1103 gtk_menu_shell_append (GTK_MENU_SHELL (demo_menu),
1104 gtk_action_create_menu_item (toggle_advanced));
1105 demo_menu_item = gtk_menu_item_new_with_mnemonic ("_Scaletempo");
1106 gtk_menu_item_set_submenu (GTK_MENU_ITEM (demo_menu_item), demo_menu);
1108 menu_bar = gtk_menu_bar_new ();
1109 gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), file_menu_item);
1110 gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), media_menu_item);
1111 gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), demo_menu_item);
1113 /* Toplevel Window */
1114 gtk_window_set_title (GTK_WINDOW (window), "Scaletempo Demo");
1115 toplevel_box = gtk_vbox_new (FALSE, 0);
1116 gtk_container_set_border_width (GTK_CONTAINER (toplevel_box), 3);
1117 gtk_container_add (GTK_CONTAINER (window), toplevel_box);
1118 gtk_box_pack_start (GTK_BOX (toplevel_box), menu_bar, FALSE, FALSE, 2);
1119 gtk_box_pack_start (GTK_BOX (toplevel_box), media_controls, FALSE, FALSE, 2);
1120 gtk_box_pack_start (GTK_BOX (toplevel_box), toolbox, FALSE, FALSE, 2);
1121 gtk_box_pack_start (GTK_BOX (toplevel_box), propbox, FALSE, FALSE, 2);
1122 gtk_box_pack_start (GTK_BOX (toplevel_box), seek_bar, FALSE, FALSE, 2);
1123 gtk_box_pack_start (GTK_BOX (toplevel_box), status_bar, FALSE, FALSE, 2);
1125 priv->window = window;
1126 priv->rate_entry = GTK_ENTRY (rate_entry);
1127 priv->status_bar = GTK_STATUSBAR (status_bar);
1128 priv->seek_range = GTK_RANGE (seek_range);
1129 priv->amount_played = GTK_LABEL (amount_played);
1130 priv->amount_to_play = GTK_LABEL (amount_to_play);
1131 priv->play_action = GTK_ACTION (play->action);
1132 priv->pause_action = GTK_ACTION (pause->action);
1133 priv->open_file = GTK_ACTION (open_file->action);
1134 priv->playlist_next = GTK_ACTION (playlist_next->action);
1136 gtk_action_set_sensitive (priv->pause_action, FALSE);
1137 gtk_action_set_visible (priv->pause_action, FALSE);
1139 gtk_widget_show_all (window);
1140 gtk_widget_grab_focus (seek_range);
1141 gtk_action_activate (priv->playlist_next);
1142 status_bar_printf (GTK_STATUSBAR (status_bar), 5,
1143 "Welcome to the Scaletempo demo.");
1145 if (!g_thread_create ((GThreadFunc) gtk_main, NULL, FALSE, &error)) {
1146 g_signal_emit (gui, demo_gui_signals[SIGNAL_ERROR], 0, error->message);
1151 /* Method wrappers */
1153 demo_gui_set_player (DemoGui * gui, DemoPlayer * player)
1155 g_return_if_fail (DEMO_IS_GUI (gui));
1156 g_return_if_fail (DEMO_IS_PLAYER (player));
1158 DEMO_GUI_GET_CLASS (gui)->set_player (gui, player);
1162 demo_gui_set_playlist (DemoGui * gui, GList * uris)
1164 g_return_if_fail (DEMO_IS_GUI (gui));
1166 DEMO_GUI_GET_CLASS (gui)->set_playlist (gui, uris);
1170 demo_gui_show (DemoGui * gui)
1172 g_return_if_fail (DEMO_IS_GUI (gui));
1174 DEMO_GUI_GET_CLASS (gui)->show (gui);
1179 /* GObject overrides */
1181 demo_gui_get_property (GObject * object,
1182 guint property_id, GValue * value, GParamSpec * pspec)
1184 //DemoGui *gui = DEMO_GUI (object);
1185 switch (property_id) {
1187 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1193 demo_gui_set_property (GObject * object,
1194 guint property_id, const GValue * value, GParamSpec * pspec)
1196 //DemoGui *gui = DEMO_GUI (object);
1197 switch (property_id) {
1199 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1205 /* GTypeInfo functions */
1207 demo_gui_init (GTypeInstance * instance, gpointer klass)
1209 DemoGui *gui = (DemoGui *) instance;
1211 DemoGuiPrivate *priv = DEMO_GUI_GET_PRIVATE (gui);
1212 priv->player = NULL;
1214 priv->now_playing = NULL;
1215 priv->is_playing = FALSE;
1216 priv->window = NULL;
1217 priv->rate_entry = NULL;
1218 priv->position_updater_id = 0;
1219 priv->seek_range = NULL;
1220 priv->amount_played = NULL;
1221 priv->amount_to_play = NULL;
1225 demo_gui_class_init (gpointer klass, gpointer class_data)
1227 DemoGuiClass *gui_class = (DemoGuiClass *) klass;
1228 GObjectClass *as_object_class = G_OBJECT_CLASS (klass);
1231 g_type_class_add_private (klass, sizeof (DemoGuiPrivate));
1234 gui_class->set_player = demo_gui_set_player_func;
1235 gui_class->set_playlist = demo_gui_set_playlist_func;
1236 gui_class->show = demo_gui_show_func;
1239 as_object_class->get_property = demo_gui_get_property;
1240 as_object_class->set_property = demo_gui_set_property;
1245 type = G_TYPE_FROM_CLASS (klass);
1246 demo_gui_signals[SIGNAL_ERROR] = g_signal_new ("error", type,
1247 G_SIGNAL_RUN_FIRST, 0, NULL, NULL,
1248 g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
1250 demo_gui_signals[SIGNAL_QUITING] = g_signal_new ("quiting", type,
1251 G_SIGNAL_RUN_FIRST, 0, NULL, NULL,
1252 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL);
1256 demo_gui_get_type (void)
1258 static GType type = 0;
1259 if (G_UNLIKELY (type == 0)) {
1260 static const GTypeInfo info = {
1261 sizeof /* Class */ (DemoGuiClass),
1262 (GBaseInitFunc) NULL,
1263 (GBaseFinalizeFunc) NULL,
1264 (GClassInitFunc) demo_gui_class_init,
1265 (GClassFinalizeFunc) NULL,
1266 (gconstpointer) NULL, /* class_data */
1267 sizeof /* Instance */ (DemoGui),
1268 /* n_preallocs */ 0,
1269 (GInstanceInitFunc) demo_gui_init,
1270 (const GTypeValueTable *) NULL
1272 type = g_type_register_static (G_TYPE_OBJECT, "DemoGui", &info, 0);