pnmixer
Volume mixer for the system tray
Data Structures | Macros | Functions
ui-popup-window.c File Reference

Popup window subsystem. More...

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
#include "audio.h"
#include "prefs.h"
#include "support-intl.h"
#include "support-log.h"
#include "support-ui.h"
#include "ui-popup-window.h"
#include "main.h"
Include dependency graph for ui-popup-window.c:

Go to the source code of this file.

Data Structures

struct  popup_window
 

Macros

#define POPUP_WINDOW_HORIZONTAL_UI_FILE   "popup-window-horizontal-gtk2.glade"
 
#define POPUP_WINDOW_VERTICAL_UI_FILE   "popup-window-vertical-gtk2.glade"
 

Functions

static void configure_vol_text (GtkScale *vol_scale)
 
static void configure_vol_increment (GtkAdjustment *vol_scale_adj)
 
static void update_mute_check (GtkToggleButton *mute_check, GCallback handler_func, gpointer handler_data, gboolean has_mute, gboolean muted)
 
static void update_volume_slider (GtkAdjustment *vol_scale_adj, gdouble volume)
 
static void grab_devices (GtkWidget *window)
 
gboolean on_popup_window_event (G_GNUC_UNUSED GtkWidget *widget, GdkEvent *event, PopupWindow *window)
 
void on_vol_scale_value_changed (GtkRange *range, PopupWindow *window)
 
void on_mute_check_toggled (G_GNUC_UNUSED GtkToggleButton *button, PopupWindow *window)
 
void on_mixer_button_clicked (G_GNUC_UNUSED GtkButton *button, PopupWindow *window)
 
static void on_audio_changed (G_GNUC_UNUSED Audio *audio, AudioEvent *event, gpointer data)
 
void popup_window_show (PopupWindow *window)
 
void popup_window_hide (PopupWindow *window)
 
void popup_window_toggle (PopupWindow *window)
 
static void popup_window_cleanup (PopupWindow *window)
 
static void popup_window_init (PopupWindow *window, Audio *audio)
 
void popup_window_reload (PopupWindow *window)
 
void popup_window_destroy (PopupWindow *window)
 
PopupWindowpopup_window_create (Audio *audio)
 

Detailed Description

Popup window subsystem.

This file holds the ui-related code for the popup window.

There are two ways to handle the slider value.

I tried both ways. The second one is a real pain in the ass. A few unexpected problems arise, it makes things complex, and ends up with dirty workarounds. So, trust me, don't try it.

The first way is much simpler, works great.

So, here's the current behavior for the slider. When you open it, it queries the audio system, and display the real volume value. Then, when you change the volume, it displays the volume as you ask it to be, not as it is. So if volume is 60, and you move it to 61, then 61 is displayed. But the truth may be that the volume is still 60, because your hardware doesn't have such fine capabilities, and the next real step will be 65.

Definition in file ui-popup-window.c.

Macro Definition Documentation

◆ POPUP_WINDOW_HORIZONTAL_UI_FILE

#define POPUP_WINDOW_HORIZONTAL_UI_FILE   "popup-window-horizontal-gtk2.glade"

Definition at line 65 of file ui-popup-window.c.

◆ POPUP_WINDOW_VERTICAL_UI_FILE

#define POPUP_WINDOW_VERTICAL_UI_FILE   "popup-window-vertical-gtk2.glade"

Definition at line 66 of file ui-popup-window.c.

Function Documentation

◆ configure_vol_increment()

static void configure_vol_increment ( GtkAdjustment *  vol_scale_adj)
static

Definition at line 102 of file ui-popup-window.c.

◆ configure_vol_text()

static void configure_vol_text ( GtkScale *  vol_scale)
static

Definition at line 75 of file ui-popup-window.c.

◆ grab_devices()

static void grab_devices ( GtkWidget *  window)
static

Definition at line 214 of file ui-popup-window.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 346 of file ui-popup-window.c.

◆ on_mixer_button_clicked()

void on_mixer_button_clicked ( G_GNUC_UNUSED GtkButton *  button,
PopupWindow window 
)

Handles the 'clicked' signal on the GtkButton 'mixer_button', therefore opening the mixer application.

Parameters
buttonthe GtkButton that received the signal.
windowuser data set when the signal handler was connected.

Definition at line 332 of file ui-popup-window.c.

◆ on_mute_check_toggled()

void on_mute_check_toggled ( G_GNUC_UNUSED GtkToggleButton *  button,
PopupWindow window 
)

Handles the 'toggled' signal on the GtkToggleButton 'mute_check', changing the mute status accordingly.

Parameters
buttonthe GtkToggleButton that received the signal.
windowuser data set when the signal handler was connected.

Definition at line 319 of file ui-popup-window.c.

◆ on_popup_window_event()

gboolean on_popup_window_event ( G_GNUC_UNUSED GtkWidget *  widget,
GdkEvent *  event,
PopupWindow window 
)

Handles 'button-press-event', 'key-press-event' and 'grab-broken-event' signals, on the GtkWindow. Used to hide the volume popup window.

Parameters
widgetthe object which received the signal.
eventthe GdkEvent which triggered this signal.
windowuser data 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 247 of file ui-popup-window.c.

◆ on_vol_scale_value_changed()

void on_vol_scale_value_changed ( GtkRange *  range,
PopupWindow window 
)

Handles the 'value-changed' signal on the GtkRange 'vol_scale', changing the voume accordingly.

There are many ways for the user to change the slider value. Think about testing them all if you touch this function. Here's a list of actions you can do to trigger this callback:

  • click somewhere on the slider
  • click on the slider's knob and drag it
  • mouse scroll on the slider
  • keyboard (when the slider has focus), here's a list of keys: Up, Down, Left, Right, Page Up, Page Down, Home, End
Parameters
rangethe GtkRange that received the signal.
windowuser data set when the signal handler was connected.

Definition at line 303 of file ui-popup-window.c.

◆ popup_window_cleanup()

static void popup_window_cleanup ( PopupWindow window)
static

Definition at line 433 of file ui-popup-window.c.

◆ popup_window_create()

PopupWindow* popup_window_create ( Audio audio)

Creates the popup window and connects all the signals.

Parameters
audiopointer to this audio subsystem.
Returns
the newly created PopupWindow instance.

Definition at line 527 of file ui-popup-window.c.

◆ popup_window_destroy()

void popup_window_destroy ( PopupWindow window)

Destroys the popup window, freeing any resources.

Parameters
windowa PopupWindow instance.

Definition at line 514 of file ui-popup-window.c.

◆ popup_window_hide()

void popup_window_hide ( PopupWindow window)

Hides the popup window.

Parameters
windowa PopupWindow instance.

Definition at line 408 of file ui-popup-window.c.

◆ popup_window_init()

static void popup_window_init ( PopupWindow window,
Audio audio 
)
static

Definition at line 451 of file ui-popup-window.c.

◆ popup_window_reload()

void popup_window_reload ( PopupWindow window)

Update the popup window according to the current preferences. This has to be called each time the preferences are modified.

Parameters
windowa PopupWindow instance.

Definition at line 497 of file ui-popup-window.c.

◆ popup_window_show()

void popup_window_show ( PopupWindow window)

Shows the popup window, and grab the focus.

Parameters
windowa PopupWindow instance.

Definition at line 379 of file ui-popup-window.c.

◆ popup_window_toggle()

void popup_window_toggle ( PopupWindow window)

Toggle the popup window (aka hide or show).

Parameters
windowa PopupWindow instance.

Definition at line 419 of file ui-popup-window.c.

◆ update_mute_check()

static void update_mute_check ( GtkToggleButton *  mute_check,
GCallback  handler_func,
gpointer  handler_data,
gboolean  has_mute,
gboolean  muted 
)
static

Definition at line 116 of file ui-popup-window.c.

◆ update_volume_slider()

static void update_volume_slider ( GtkAdjustment *  vol_scale_adj,
gdouble  volume 
)
static

Definition at line 141 of file ui-popup-window.c.