pnmixer
Volume mixer for the system tray
Data Structures | Macros | Typedefs | Enumerations | Functions
ui-tray-icon.c File Reference

Tray icon subsystem. More...

#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <glib.h>
#include <gtk/gtk.h>
#include "audio.h"
#include "prefs.h"
#include "support-intl.h"
#include "support-log.h"
#include "support-ui.h"
#include "ui-tray-icon.h"
#include "main.h"
Include dependency graph for ui-tray-icon.c:

Go to the source code of this file.

Data Structures

struct  vol_meter
 
struct  tray_icon
 

Macros

#define ICON_MIN_SIZE   16
 

Typedefs

typedef struct vol_meter VolMeter
 

Enumerations

enum  {
  VOLUME_MUTED, VOLUME_OFF, VOLUME_LOW, VOLUME_MEDIUM,
  VOLUME_HIGH, N_VOLUME_PIXBUFS
}
 

Functions

static GdkPixbuf * pixbuf_new_from_file (const gchar *filename)
 
static GdkPixbuf * pixbuf_new_from_stock (const gchar *icon_name, gint size)
 
static void pixbuf_array_free (GdkPixbuf **pixbufs)
 
static GdkPixbuf ** pixbuf_array_new (int size)
 
static void vol_meter_free (VolMeter *vol_meter)
 
static VolMetervol_meter_new (void)
 
static GdkPixbuf * vol_meter_draw (VolMeter *vol_meter, GdkPixbuf *pixbuf, int volume)
 
static void update_status_icon_pixbuf (GtkStatusIcon *status_icon, GdkPixbuf **pixbufs, VolMeter *vol_meter, gdouble volume, gboolean muted)
 
static void update_status_icon_tooltip (GtkStatusIcon *status_icon, const gchar *card, const gchar *channel, gdouble volume, gboolean has_mute, gboolean muted)
 
static void on_activate (G_GNUC_UNUSED GtkStatusIcon *status_icon, G_GNUC_UNUSED TrayIcon *icon)
 
static void on_popup_menu (GtkStatusIcon *status_icon, guint button, guint activate_time, G_GNUC_UNUSED TrayIcon *icon)
 
static gboolean on_button_release_event (G_GNUC_UNUSED GtkStatusIcon *status_icon, GdkEventButton *event, G_GNUC_UNUSED TrayIcon *icon)
 
static gboolean on_scroll_event (G_GNUC_UNUSED GtkStatusIcon *status_icon, GdkEventScroll *event, TrayIcon *icon)
 
static gboolean on_size_changed (G_GNUC_UNUSED GtkStatusIcon *status_icon, gint size, TrayIcon *icon)
 
static void on_audio_changed (G_GNUC_UNUSED Audio *audio, AudioEvent *event, gpointer data)
 
void tray_icon_reload (TrayIcon *icon)
 
void tray_icon_destroy (TrayIcon *icon)
 
TrayIcontray_icon_create (Audio *audio)
 

Detailed Description

Tray icon subsystem.

This file holds the ui-related code for the system tray icon.

Definition in file ui-tray-icon.c.

Macro Definition Documentation

◆ ICON_MIN_SIZE

#define ICON_MIN_SIZE   16

Definition at line 36 of file ui-tray-icon.c.

Typedef Documentation

◆ VolMeter

typedef struct vol_meter VolMeter

Definition at line 195 of file ui-tray-icon.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
VOLUME_MUTED 
VOLUME_OFF 
VOLUME_LOW 
VOLUME_MEDIUM 
VOLUME_HIGH 
N_VOLUME_PIXBUFS 

Definition at line 38 of file ui-tray-icon.c.

Function Documentation

◆ on_activate()

static void on_activate ( G_GNUC_UNUSED GtkStatusIcon *  status_icon,
G_GNUC_UNUSED TrayIcon icon 
)
static

Handles the 'activate' signal on the GtkStatusIcon, bringing up or hiding the volume popup window. Usually triggered by left-click.

Parameters
status_iconthe object which received the signal.
iconTrayIcon instance set when the signal handler was connected.

Definition at line 391 of file ui-tray-icon.c.

◆ on_audio_changed()

static void on_audio_changed ( G_GNUC_UNUSED Audio audio,
AudioEvent event,
gpointer  data 
)
static

Handle signals from the audio subsystem.

Parameters
audiothe Audio instance that emitted the signal.
eventthe AudioEvent containing useful information.
datauser supplied data.

Definition at line 519 of file ui-tray-icon.c.

◆ on_button_release_event()

static gboolean on_button_release_event ( G_GNUC_UNUSED GtkStatusIcon *  status_icon,
GdkEventButton *  event,
G_GNUC_UNUSED TrayIcon icon 
)
static

Handles 'button-release-event' signal on the GtkStatusIcon. Only used for middle-click, which runs the middle click action.

Parameters
status_iconthe object which received the signal.
eventthe GdkEventButton which triggered this signal.
iconTrayIcon instance set when the signal handler was connected.
Returns
TRUE to stop other handlers from being invoked for the event. FALSE to propagate the event further.

Definition at line 426 of file ui-tray-icon.c.

◆ on_popup_menu()

static void on_popup_menu ( GtkStatusIcon *  status_icon,
guint  button,
guint  activate_time,
G_GNUC_UNUSED TrayIcon icon 
)
static

Handles the 'popup-menu' signal on the GtkStatusIcon, bringing up the context popup menu. Usually triggered by right-click.

Parameters
status_iconthe object which received the signal.
buttonthe button that was pressed, or 0 if the signal is not emitted in response to a button press event.
activate_timethe timestamp of the event that triggered the signal emission.
iconTrayIcon instance set when the signal handler was connected.

Definition at line 409 of file ui-tray-icon.c.

◆ on_scroll_event()

static gboolean on_scroll_event ( G_GNUC_UNUSED GtkStatusIcon *  status_icon,
GdkEventScroll *  event,
TrayIcon icon 
)
static

Handles 'scroll-event' signal on the GtkStatusIcon, changing the volume accordingly.

Parameters
status_iconthe object which received the signal.
eventthe GdkEventScroll which triggered this signal.
iconTrayIcon instance set when the signal handler was connected.
Returns
TRUE to stop other handlers from being invoked for the event. FALSE to propagate the event further

Definition at line 467 of file ui-tray-icon.c.

◆ on_size_changed()

static gboolean on_size_changed ( G_GNUC_UNUSED GtkStatusIcon *  status_icon,
gint  size,
TrayIcon icon 
)
static

Handles the 'size-changed' signal on the GtkStatusIcon. Happens when the panel holding the tray icon is resized. Also happens at startup during the tray icon creation.

Parameters
status_iconthe object which received the signal.
sizethe new size.
iconTrayIcon instance set when the signal handler was connected.
Returns
FALSE, so that Gtk+ scales the icon as necessary.

Definition at line 489 of file ui-tray-icon.c.

◆ pixbuf_array_free()

static void pixbuf_array_free ( GdkPixbuf **  pixbufs)
static

Definition at line 132 of file ui-tray-icon.c.

◆ pixbuf_array_new()

static GdkPixbuf** pixbuf_array_new ( int  size)
static

Definition at line 147 of file ui-tray-icon.c.

◆ pixbuf_new_from_file()

static GdkPixbuf* pixbuf_new_from_file ( const gchar *  filename)
static

This is an internally used function to create GdkPixbufs.

Parameters
filenamefilename to create the GtkPixbuf from
Returns
the new GdkPixbuf, NULL on failure

Definition at line 58 of file ui-tray-icon.c.

◆ pixbuf_new_from_stock()

static GdkPixbuf* pixbuf_new_from_stock ( const gchar *  icon_name,
gint  size 
)
static

Looks up icons based on the currently selected theme.

Parameters
icon_nameicon name to look up
sizesize of the icon
Returns
the corresponding theme icon, NULL on failure, use g_object_unref() to release the reference to the icon

Definition at line 96 of file ui-tray-icon.c.

◆ tray_icon_create()

TrayIcon* tray_icon_create ( Audio audio)

Creates the tray icon and connects all the signals.

Returns
the newly created TrayIcon instance.

Definition at line 582 of file ui-tray-icon.c.

◆ tray_icon_destroy()

void tray_icon_destroy ( TrayIcon icon)

Destroys the tray icon, freeing any resources.

Parameters
icona TrayIcon instance.

Definition at line 565 of file ui-tray-icon.c.

◆ tray_icon_reload()

void tray_icon_reload ( TrayIcon icon)

Update the tray icon according to the current preferences and the current audio status. Both can't be separated. This has to be called each time the preferences are modified.

Parameters
icona TrayIcon instance.

Definition at line 536 of file ui-tray-icon.c.

◆ update_status_icon_pixbuf()

static void update_status_icon_pixbuf ( GtkStatusIcon *  status_icon,
GdkPixbuf **  pixbufs,
VolMeter vol_meter,
gdouble  volume,
gboolean  muted 
)
static

Definition at line 318 of file ui-tray-icon.c.

◆ update_status_icon_tooltip()

static void update_status_icon_tooltip ( GtkStatusIcon *  status_icon,
const gchar *  card,
const gchar *  channel,
gdouble  volume,
gboolean  has_mute,
gboolean  muted 
)
static

Definition at line 345 of file ui-tray-icon.c.

◆ vol_meter_draw()

static GdkPixbuf* vol_meter_draw ( VolMeter vol_meter,
GdkPixbuf *  pixbuf,
int  volume 
)
static

Definition at line 242 of file ui-tray-icon.c.

◆ vol_meter_free()

static void vol_meter_free ( VolMeter vol_meter)
static

Definition at line 199 of file ui-tray-icon.c.

◆ vol_meter_new()

static VolMeter* vol_meter_new ( void  )
static

Definition at line 213 of file ui-tray-icon.c.