pnmixer
Volume mixer for the system tray
Functions | Variables
main.c File Reference

Main program entry point & high-level public functions. More...

#include <stdlib.h>
#include <glib.h>
#include "main.h"
#include "audio.h"
#include "notif.h"
#include "hotkeys.h"
#include "prefs.h"
#include "support-intl.h"
#include "support-log.h"
#include "ui-about-dialog.h"
#include "ui-prefs-dialog.h"
#include "ui-popup-menu.h"
#include "ui-popup-window.h"
#include "ui-tray-icon.h"
Include dependency graph for main.c:

Go to the source code of this file.

Functions

static void run_command (const gchar *cmd)
 
void run_mixer_command (void)
 
void run_custom_command (void)
 
static void prefs_dialog_response_cb (PrefsDialog *this_dialog, gint response_id)
 
void run_prefs_dialog (void)
 
void run_about_dialog (void)
 
void run_error_dialog (const char *fmt,...)
 
gint run_audio_error_dialog (void)
 
void do_toggle_popup_window (void)
 
void do_show_popup_menu (GtkMenuPositionFunc func, gpointer data, guint button, guint activate_time)
 
static void on_audio_changed (Audio *audio, AudioEvent *event, G_GNUC_UNUSED gpointer data)
 
int main (int argc, char *argv[])
 

Variables

static Audioaudio
 
static PopupMenupopup_menu
 
static PopupWindowpopup_window
 
static TrayIcontray_icon
 
static Hotkeyshotkeys
 
static Notifnotif
 
static GtkWindow * main_window
 
static PrefsDialogprefs_dialog
 
static AboutDialogabout_dialog
 
static gboolean version = FALSE
 
static GOptionEntry option_entries []
 

Detailed Description

Main program entry point & high-level public functions.

The main program entry point. Also handles creating and opening the widgets. Declares some high-level public functions needed by some widgets.

Definition in file main.c.

Function Documentation

◆ do_show_popup_menu()

void do_show_popup_menu ( GtkMenuPositionFunc  func,
gpointer  data,
guint  button,
guint  activate_time 
)

Show the popup menu.

Definition at line 277 of file main.c.

◆ do_toggle_popup_window()

void do_toggle_popup_window ( void  )

Toggle the popup window

Definition at line 259 of file main.c.

◆ main()

int main ( int  argc,
char *  argv[] 
)

Program entry point. Initializes gtk+, calls the widget creating functions and starts the main loop.

Parameters
argccount of arguments
argvstring array of arguments
Returns
0 for success, otherwise error code

Definition at line 326 of file main.c.

◆ on_audio_changed()

static void on_audio_changed ( Audio audio,
AudioEvent event,
G_GNUC_UNUSED 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 291 of file main.c.

◆ prefs_dialog_response_cb()

static void prefs_dialog_response_cb ( PrefsDialog this_dialog,
gint  response_id 
)
static

Bring up the preferences window.

Definition at line 118 of file main.c.

◆ run_about_dialog()

void run_about_dialog ( void  )

Run the about dialog.

Definition at line 168 of file main.c.

◆ run_audio_error_dialog()

gint run_audio_error_dialog ( void  )

Emits a warning if the sound connection is lost, usually via a dialog window (with option to reinitialize sound) or stderr. Asks for alsa reload, check the return value to know.

Returns
the response from the dialog window

Definition at line 223 of file main.c.

◆ run_command()

static void run_command ( const gchar *  cmd)
static

Runs a given command via g_spawn_command_line_async().

Parameters
cmdthe command to run

Definition at line 62 of file main.c.

◆ run_custom_command()

void run_custom_command ( void  )

Run a custom command.

Definition at line 99 of file main.c.

◆ run_error_dialog()

void run_error_dialog ( const char *  fmt,
  ... 
)

Report an error, usually via a dialog window or on stderr.

Parameters
fmtthe error
...more string segments in the format of printf

Definition at line 188 of file main.c.

◆ run_mixer_command()

void run_mixer_command ( void  )

Run the specified mixer application.

Definition at line 79 of file main.c.

◆ run_prefs_dialog()

void run_prefs_dialog ( void  )

Definition at line 151 of file main.c.

Variable Documentation

◆ about_dialog

Definition at line 54 of file main.c.

◆ audio

Audio* audio
static

Definition at line 40 of file main.c.

◆ hotkeys

Hotkeys* hotkeys
static

Definition at line 44 of file main.c.

◆ main_window

GtkWindow* main_window
static

Definition at line 50 of file main.c.

◆ notif

Notif* notif
static

Definition at line 45 of file main.c.

◆ option_entries

GOptionEntry option_entries[]
static
Initial value:
= {
{ "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Show version and exit", NULL },
{ "debug", 'd', 0, G_OPTION_ARG_NONE, &want_debug, "Run in debug mode", NULL },
{ NULL, 0, 0, 0, NULL, NULL, NULL }
}
gboolean want_debug
Definition: support-log.c:38
static gboolean version
Definition: main.c:310

Definition at line 311 of file main.c.

◆ popup_menu

Definition at line 41 of file main.c.

◆ popup_window

Definition at line 42 of file main.c.

◆ prefs_dialog

Definition at line 53 of file main.c.

◆ tray_icon

Definition at line 43 of file main.c.

◆ version

gboolean version = FALSE
static

Definition at line 310 of file main.c.