Пример #1
0
static void
_stream_volume_notify_cb (GObject       *object,
                          GParamSpec    *pspec,
                          MpdVolumeTile *self)
{
  update_volume_slider (self);
}
Пример #2
0
/**
 * Handle signals from the audio subsystem.
 *
 * @param audio the Audio instance that emitted the signal.
 * @param event the AudioEvent containing useful information.
 * @param data user supplied data.
 */
static void
on_audio_changed(G_GNUC_UNUSED Audio *audio, AudioEvent *event, gpointer data)
{
	PopupWindow *window = (PopupWindow *) data;
	GtkWidget *popup_window = window->popup_window;

	/* Nothing to do if the window is hidden.
	 * The window will be updated anyway when shown.
	 */
	if (!gtk_widget_get_visible(popup_window))
		return;

	/* If the user changes the volume through the popup window,
	 * we MUST NOT update the slider value, it's been done already.
	 * It means that, as long as the popup window is visible,
	 * the slider value reflects the value set by user,
	 * and not the real value reported by the audio system.
	 */
	if (event->user == AUDIO_USER_POPUP)
		return;

	/* Let's update now */
	update_mute_check(GTK_TOGGLE_BUTTON(window->mute_check),
	                  G_CALLBACK(on_mute_check_toggled), window, event->muted);
	update_volume_slider(window->vol_scale_adj, event->volume);
}
Пример #3
0
static void
mpd_volume_tile_set_sink (MpdVolumeTile   *self,
                          GvcMixerStream  *sink)
{
  MpdVolumeTilePrivate *priv = GET_PRIVATE (self);
  bool do_notify;

  do_notify = sink != priv->sink;

  if (priv->sink)
  {
    g_signal_handlers_disconnect_by_func (priv->sink,
                                          _stream_volume_notify_cb,
                                          self);
    g_object_unref (priv->sink);
    priv->sink = NULL;
  }

  if (sink)
  {
    priv->sink = g_object_ref (sink);

    g_signal_connect (priv->sink, "notify::volume",
                      G_CALLBACK (_stream_volume_notify_cb), self);

    update_volume_slider (self);
  }

  if (do_notify)
  {
    g_object_notify (G_OBJECT (self), "sink");
  }
}
Пример #4
0
/**
 * Shows the popup window, and grab the focus.
 *
 * @param window a PopupWindow instance.
 */
void
popup_window_show(PopupWindow *window)
{
	GtkWidget *popup_window = window->popup_window;
	GtkWidget *vol_scale = window->vol_scale;

	/* Update window elements at first */
	update_mute_check(GTK_TOGGLE_BUTTON(window->mute_check),
	                  G_CALLBACK(on_mute_check_toggled), window,
	                  audio_is_muted(window->audio));
	update_volume_slider(window->vol_scale_adj,
	                     audio_get_volume(window->audio));

	/* Show the window */
	gtk_widget_show_now(popup_window);

	/* Give focus to volume scale */
	gtk_widget_grab_focus(vol_scale);

	/* Grab mouse and keyboard */
	grab_devices(popup_window);
}