Ejemplo n.º 1
0
/**
 * Updates the tray icon. Usually called after volume has been muted
 * or changed.
 */
void
update_tray_icon(void)
{
	int muted;
	int tmpvol = getvol();
	char tooltip[60];
	gchar *active_card_name = (alsa_get_active_card())->name;
	const char *active_channel = alsa_get_active_channel();

	muted = ismuted();

	if (muted == 1) {
		GdkPixbuf *icon;

		if (tmpvol == 0)
			icon = status_icons[VOLUME_OFF];
		else if (tmpvol < 33)
			icon = status_icons[VOLUME_LOW];
		else if (tmpvol < 66)
			icon = status_icons[VOLUME_MEDIUM];
		else
			icon = status_icons[VOLUME_HIGH];
		sprintf(tooltip, _("%s (%s)\nVolume: %d %%"), active_card_name,
			active_channel,
			tmpvol);

		if (vol_meter_row) {
			GdkPixbuf *old_icon = icon_copy;
			icon_copy = gdk_pixbuf_copy(icon);
			draw_vol_meter(icon_copy, draw_offset, 5,
				       (tmpvol * vol_div_factor));
			if (old_icon)
				g_object_unref(old_icon);
			gtk_status_icon_set_from_pixbuf(tray_icon, icon_copy);
		} else
			gtk_status_icon_set_from_pixbuf(tray_icon, icon);
	} else {
		gtk_status_icon_set_from_pixbuf(tray_icon, status_icons[VOLUME_MUTED]);
		sprintf(tooltip, _("%s (%s)\nVolume: %d %%\nMuted"), active_card_name,
			active_channel, tmpvol);
	}
	gtk_status_icon_set_tooltip_text(tray_icon, tooltip);
}
Ejemplo n.º 2
0
/**
 * Checks whether playback is muted, updates the icon
 * and returns the result of ismuted().
 *
 * @param set_check whether the GtkCheckButton 'Mute' on the
 * volume popup_window is updated
 * @return result of ismuted()
 */
int get_mute_state(gboolean set_check) {
  int muted;
  int tmpvol = getvol();
  char tooltip [60];

  muted = ismuted();

  if( muted == 1 ) {
    GdkPixbuf *icon;
    if (set_check)
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mute_check), FALSE);
    if (tmpvol < 33)
      icon = status_icons[1];
    else if (tmpvol < 66)
      icon = status_icons[2];
    else
      icon = status_icons[3];
    sprintf(tooltip, _("Volume: %d %%"), tmpvol);

    if (vol_meter_row) {
      GdkPixbuf* old_icon = icon_copy;
      icon_copy = gdk_pixbuf_copy(icon);
      draw_vol_meter(icon_copy,draw_offset,5,(tmpvol*vol_div_factor));
      if (old_icon)
	g_object_unref(old_icon);
      gtk_status_icon_set_from_pixbuf(tray_icon, icon_copy);
    } else
      gtk_status_icon_set_from_pixbuf(tray_icon, icon);
  } else {
    if (set_check)
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mute_check), TRUE);
    gtk_status_icon_set_from_pixbuf(tray_icon, status_icons[0]);
    sprintf(tooltip, _("Volume: %d %%\nMuted"), tmpvol);
  }
  gtk_status_icon_set_tooltip_text(tray_icon, tooltip);
  return muted;
}