--- /dev/null
+diff --git a/configure.ac b/configure.ac
+index 4397463..c66273c 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -26,7 +26,7 @@ m4_define([xfce4_mixer_version_minor], [11])
+ m4_define([xfce4_mixer_version_micro], [0])
+ m4_define([xfce4_mixer_version_nano], []) dnl leave this empty to have no nano version
+ m4_define([xfce4_mixer_version_build], [rfe42d58])
+-m4_define([xfce4_mixer_version_tag], [])
++m4_define([xfce4_mixer_version_tag], [git])
+ m4_define([xfce4_mixer_version], [xfce4_mixer_version_major().xfce4_mixer_version_minor().xfce4_mixer_version_micro()ifelse(xfce4_mixer_version_nano(), [], [], [.xfce4_mixer_version_nano()])ifelse(xfce4_mixer_version_tag(), [git], [xfce4_mixer_version_tag()-xfce4_mixer_version_build()], [xfce4_mixer_version_tag()])])
+
+ dnl *******************************************
+@@ -93,21 +93,20 @@ AC_CHECK_LIB([m],[round])
+ dnl ***********************************
+ dnl *** Check for required packages ***
+ dnl ***********************************
+-XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.24.0])
+-XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.24.0])
++XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.42.0])
++XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.42.0])
+ XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [0.84])
+ XDT_CHECK_PACKAGE([GST_PLUGINS_BASE], [gstreamer-plugins-base-0.10], [0.10.25])
+-XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.20.0])
+-XDT_CHECK_PACKAGE([UNIQUE], [unique-1.0], [1.1])
+-XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.10.0])
+-XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.10.0])
+-XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.10.0])
+-XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.10.0])
++XDT_CHECK_PACKAGE([GTK], [gtk+-3.0], [3.14.0])
++XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.12.0])
++XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.12.0])
++XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-2.0], [4.12.0])
++XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.12.0])
+
+ dnl ***********************************
+ dnl *** Check for optional packages ***
+ dnl ***********************************
+-XDT_CHECK_OPTIONAL_PACKAGE([KEYBINDER], [keybinder], [0.2.2], [keybinder],
++XDT_CHECK_OPTIONAL_PACKAGE([KEYBINDER], [keybinder-3.0], [0.3], [keybinder],
+ [keybinder Support])
+
+ dnl ***********************************
+diff --git a/icons/16x16/Makefile.am b/icons/16x16/Makefile.am
+index 803a2e4..ace4a07 100644
+--- a/icons/16x16/Makefile.am
++++ b/icons/16x16/Makefile.am
+@@ -1,4 +1,4 @@
+-iconsdir = $(pkgdatadir)/icons/hicolor/16x16/status
++iconsdir = $(datadir)/xfce4/mixer/icons/hicolor/16x16/status
+ icons_DATA = audio-input-microphone-muted.png
+
+ EXTRA_DIST = $(icons_DATA)
+diff --git a/icons/Makefile.am b/icons/Makefile.am
+index 70638c1..035476a 100644
+--- a/icons/Makefile.am
++++ b/icons/Makefile.am
+@@ -4,17 +4,4 @@ SUBDIRS = \
+ 16x16 \
+ scalable
+
+-gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
+-
+-install-data-hook:
+- @-if test -z "$(DESTDIR)"; then \
+- echo "Updating Gtk icon cache."; \
+- $(gtk_update_icon_cache); \
+- else \
+- echo "*** Icon cache not updated. Remember to run:"; \
+- echo "***"; \
+- echo "*** $(gtk_update_icon_cache)"; \
+- echo "***"; \
+- fi
+-
+ # vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
+diff --git a/icons/scalable/Makefile.am b/icons/scalable/Makefile.am
+index 5bfc12c..5212e63 100644
+--- a/icons/scalable/Makefile.am
++++ b/icons/scalable/Makefile.am
+@@ -1,4 +1,4 @@
+-iconsdir = $(pkgdatadir)/icons/hicolor/scalable/status
++iconsdir = $(datadir)/xfce4/mixer/icons/hicolor/scalable/status
+ icons_DATA = audio-input-microphone-muted.svg
+
+ EXTRA_DIST = $(icons_DATA)
+diff --git a/libxfce4mixer/Makefile.am b/libxfce4mixer/Makefile.am
+index 792a95e..e864ea8 100644
+--- a/libxfce4mixer/Makefile.am
++++ b/libxfce4mixer/Makefile.am
+@@ -25,7 +25,7 @@ libxfce4mixer_la_CPPFLAGS = \
+ -DDATADIR=\"$(datadir)\" \
+ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
+ -DG_LOG_DOMAIN=\"libxfce4mixer\" \
+- -DMIXER_DATADIR=\"$(pkgdatadir)\"
++ -DMIXER_DATADIR=\"$(datadir)/xfce4/mixer\"
+
+ libxfce4mixer_la_CFLAGS = \
+ $(PLATFORM_CFLAGS) \
+diff --git a/libxfce4mixer/xfce-mixer-debug.h b/libxfce4mixer/xfce-mixer-debug.h
+index 4ade97c..8643d4d 100644
+--- a/libxfce4mixer/xfce-mixer-debug.h
++++ b/libxfce4mixer/xfce-mixer-debug.h
+@@ -34,7 +34,7 @@ void xfce_mixer_debug_real (const gchar *log_domain,
+ const gchar *file,
+ const gchar *func,
+ gint line,
+- const gchar *format, ...);
++ const gchar *format, ...) G_GNUC_PRINTF(5, 6);
+ void xfce_mixer_dump_gst_data (void);
+
+
+diff --git a/panel-plugin/mixer.desktop.in b/panel-plugin/mixer.desktop.in
+index f4e7637..728f808 100644
+--- a/panel-plugin/mixer.desktop.in
++++ b/panel-plugin/mixer.desktop.in
+@@ -6,3 +6,4 @@ Icon=multimedia-volume-control
+ X-XFCE-Internal=false
+ X-XFCE-Module=mixer
+ X-XFCE-Unique=true
++X-XFCE-API=2.0
+diff --git a/panel-plugin/xfce-mixer-plugin.c b/panel-plugin/xfce-mixer-plugin.c
+index 949e63e..85f4805 100644
+--- a/panel-plugin/xfce-mixer-plugin.c
++++ b/panel-plugin/xfce-mixer-plugin.c
+@@ -276,7 +276,7 @@ xfce_mixer_plugin_init (XfceMixerPlugin *mixer_plugin)
+ xfce_mixer_dump_gst_data ();
+
+ /* Create container for the plugin */
+- mixer_plugin->hvbox = GTK_WIDGET (xfce_hvbox_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0));
++ mixer_plugin->hvbox = GTK_WIDGET (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0));
+ xfce_panel_plugin_add_action_widget (XFCE_PANEL_PLUGIN (mixer_plugin), mixer_plugin->hvbox);
+ gtk_container_add (GTK_CONTAINER (mixer_plugin), mixer_plugin->hvbox);
+ gtk_widget_show (mixer_plugin->hvbox);
+@@ -300,7 +300,6 @@ xfce_mixer_plugin_construct (XfcePanelPlugin *plugin)
+ {
+ XfceMixerPlugin *mixer_plugin = XFCE_MIXER_PLUGIN (plugin);
+ GtkWidget *command_menu_item;
+- GtkWidget *command_image;
+
+ xfce_panel_plugin_menu_show_configure (plugin);
+
+@@ -311,10 +310,7 @@ xfce_mixer_plugin_construct (XfcePanelPlugin *plugin)
+ gtk_widget_show (mixer_plugin->mute_menu_item);
+
+ /* Add menu item for running the user-defined command */
+- command_image = gtk_image_new_from_icon_name ("multimedia-volume-control", GTK_ICON_SIZE_MENU);
+- gtk_widget_show (command_image);
+- command_menu_item = gtk_image_menu_item_new_with_mnemonic (_("Run Audio Mi_xer"));
+- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (command_menu_item), command_image);
++ command_menu_item = gtk_menu_item_new_with_mnemonic (_("Run Audio Mi_xer"));
+ xfce_panel_plugin_menu_insert_item (plugin, GTK_MENU_ITEM (command_menu_item));
+ g_signal_connect_swapped (G_OBJECT (command_menu_item), "activate", G_CALLBACK (xfce_mixer_plugin_command_item_activated), mixer_plugin);
+ gtk_widget_show (command_menu_item);
+@@ -608,6 +604,9 @@ xfce_mixer_plugin_size_changed (XfcePanelPlugin *plugin,
+ gint size)
+ {
+ XfceMixerPlugin *mixer_plugin = XFCE_MIXER_PLUGIN (plugin);
++ GtkBorder button_padding;
++ gint xthickness;
++ gint ythickness;
+ gint icon_size;
+
+ g_return_val_if_fail (mixer_plugin != NULL, FALSE);
+@@ -616,7 +615,11 @@ xfce_mixer_plugin_size_changed (XfcePanelPlugin *plugin,
+ size /= xfce_panel_plugin_get_nrows (XFCE_PANEL_PLUGIN (mixer_plugin));
+
+ /* Determine size for the volume button icons */
+- icon_size = size - 2 - 2 * MAX (mixer_plugin->button->style->xthickness, mixer_plugin->button->style->ythickness);
++ gtk_style_context_get_padding (gtk_widget_get_style_context (GTK_WIDGET (mixer_plugin->button)), GTK_STATE_FLAG_NORMAL,
++ &button_padding);
++ xthickness = button_padding.left + button_padding.right;
++ ythickness = button_padding.top + button_padding.bottom;
++ icon_size = size - 2 - MAX (xthickness, ythickness);
+
+ /* Set volume button icon size and update the volume button */
+ xfce_volume_button_set_icon_size (XFCE_VOLUME_BUTTON (mixer_plugin->button), icon_size);
+diff --git a/panel-plugin/xfce-plugin-dialog.c b/panel-plugin/xfce-plugin-dialog.c
+index f89f872..64dbf4d 100644
+--- a/panel-plugin/xfce-plugin-dialog.c
++++ b/panel-plugin/xfce-plugin-dialog.c
+@@ -142,7 +142,7 @@ xfce_plugin_dialog_new (XfcePanelPlugin *plugin)
+ static void
+ xfce_plugin_dialog_create_contents (XfcePluginDialog *dialog)
+ {
+- GtkWidget *table;
++ GtkWidget *grid;
+ GtkWidget *button;
+ GtkWidget *label;
+
+@@ -151,33 +151,35 @@ xfce_plugin_dialog_create_contents (XfcePluginDialog *dialog)
+
+ xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dialog), _("Configure the sound card and mixer track"));
+
+- button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
++ button = gtk_button_new_with_mnemonic (_("_Close"));
++ gtk_button_set_image (GTK_BUTTON (button),
++ gtk_image_new_from_icon_name ("window-close", GTK_ICON_SIZE_BUTTON));
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_CLOSE);
+ gtk_widget_show (button);
+
+- table = gtk_table_new (2, 2, FALSE);
+- gtk_table_set_row_spacings (GTK_TABLE (table), 12);
+- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
+- gtk_container_set_border_width (GTK_CONTAINER (table), 6);
+- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), table);
+- gtk_widget_show (table);
++ grid = gtk_grid_new ();
++ g_object_set (G_OBJECT (grid), "row-spacing", 6, "column-spacing", 12, "margin-top", 6, "margin-bottom", 6, NULL);
++ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), grid);
++ gtk_widget_show (grid);
+
+ label = gtk_label_new_with_mnemonic (_("Sound _card:"));
+- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
++ gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
+ gtk_widget_show (label);
+
+ dialog->card_combo = xfce_mixer_card_combo_new (NULL);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->card_combo);
+- gtk_table_attach (GTK_TABLE (table), dialog->card_combo, 1, 2, 0, 1, GTK_FILL|GTK_EXPAND, GTK_SHRINK, 0, 0);
++ g_object_set (G_OBJECT (dialog->card_combo), "halign", GTK_ALIGN_FILL, "hexpand", TRUE, NULL);
++ gtk_grid_attach (GTK_GRID (grid), dialog->card_combo, 1, 0, 1, 1);
+ gtk_widget_show (dialog->card_combo);
+
+ label = gtk_label_new_with_mnemonic (_("Mixer _track:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->track_combo);
+- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
++ gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);
+ gtk_widget_show (label);
+
+ dialog->track_combo = xfce_mixer_track_combo_new (NULL, NULL);
+- gtk_table_attach (GTK_TABLE (table), dialog->track_combo, 1, 2, 1, 2, GTK_FILL|GTK_EXPAND, GTK_SHRINK, 0, 0);
++ g_object_set (G_OBJECT (dialog->track_combo), "halign", GTK_ALIGN_FILL, "hexpand", TRUE, NULL);
++ gtk_grid_attach (GTK_GRID (grid), dialog->track_combo, 1, 1, 1, 1);
+ gtk_widget_show (dialog->track_combo);
+
+ /* Hack to initialize the widget state */
+diff --git a/panel-plugin/xfce-volume-button.c b/panel-plugin/xfce-volume-button.c
+index 6877614..0481a66 100644
+--- a/panel-plugin/xfce-volume-button.c
++++ b/panel-plugin/xfce-volume-button.c
+@@ -152,7 +152,7 @@ struct _XfceVolumeButton
+ GtkWidget *vbox;
+
+ /* Adjustment for the volume range and current value */
+- GtkObject *adjustment;
++ GtkAdjustment *adjustment;
+
+ /* Icon size currently used */
+ gint icon_size;
+@@ -292,13 +292,16 @@ xfce_volume_button_init (XfceVolumeButton *button)
+
+ /* Make the button look flat and make it never grab the focus */
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+- gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
++ gtk_widget_set_focus_on_click (GTK_WIDGET (button), FALSE);
+ gtk_widget_set_can_default (GTK_WIDGET (button), FALSE);
+ gtk_widget_set_can_focus (GTK_WIDGET (button), FALSE);
+
+ /* Connect signal for theme changes */
+ g_signal_connect_swapped (gtk_icon_theme_get_default (), "changed", G_CALLBACK (xfce_volume_button_update_icons), button);
+
++ /* Intercept scroll events */
++ gtk_widget_add_events (GTK_WIDGET (button), GDK_SCROLL_MASK);
++
+ /* Update the state of the button */
+ xfce_volume_button_update (button);
+ }
+@@ -499,13 +502,13 @@ xfce_volume_button_create_dock_contents (XfceVolumeButton *button)
+ * not matter here since only one of the boxes it holds will be visibe at any
+ * time depending on the panel orientation
+ */
+- box = gtk_vbox_new (TRUE, 6);
++ box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (box), 2);
+ gtk_container_add (GTK_CONTAINER (frame), box);
+ gtk_widget_show (box);
+
+ /* Container for the widgets shown in vertical mode */
+- button->hbox = gtk_hbox_new(FALSE, 6);
++ button->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_box_pack_start (GTK_BOX (box), button->hbox, TRUE, TRUE, 0);
+
+ /* Show the position of lowest and highest volume through icons */
+@@ -513,7 +516,7 @@ xfce_volume_button_create_dock_contents (XfceVolumeButton *button)
+ gtk_box_pack_start (GTK_BOX (button->hbox), image, TRUE, TRUE, 0);
+ gtk_widget_show (image);
+
+- scale = gtk_hscale_new (GTK_ADJUSTMENT (button->adjustment));
++ scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (button->adjustment));
+ gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
+ gtk_box_pack_start (GTK_BOX (button->hbox), scale, TRUE, TRUE, 0);
+ gtk_widget_set_size_request (scale, SCALE_SIZE, -1);
+@@ -525,10 +528,10 @@ xfce_volume_button_create_dock_contents (XfceVolumeButton *button)
+ gtk_widget_show (image);
+
+ /* Container for the widgets shown in horizontal mode */
+- button->vbox = gtk_vbox_new(FALSE, 6);
++ button->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
+ gtk_box_pack_start (GTK_BOX (box), button->vbox, TRUE, TRUE, 0);
+
+- scale = gtk_vscale_new (GTK_ADJUSTMENT (button->adjustment));
++ scale = gtk_scale_new (GTK_ORIENTATION_VERTICAL, GTK_ADJUSTMENT (button->adjustment));
+ gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
+ gtk_range_set_inverted (GTK_RANGE (scale), TRUE);
+ gtk_box_pack_start (GTK_BOX (button->vbox), scale, TRUE, TRUE, 0);
+@@ -549,6 +552,72 @@ xfce_volume_button_create_dock_contents (XfceVolumeButton *button)
+
+
+
++static gboolean
++xfce_volume_button_grab_input (XfceVolumeButton *button)
++{
++ GtkWidget *dock = button->dock;
++ GdkWindow *window = gtk_widget_get_window (dock);
++ GdkDisplay *display = gtk_widget_get_display (dock);
++#if GTK_CHECK_VERSION(3, 20, 0)
++ GdkSeat *seat = gdk_display_get_default_seat (display);
++#else
++ GdkDeviceManager *device_manager = gdk_display_get_device_manager (display);
++ GdkDevice *pointer = gdk_device_manager_get_client_pointer (device_manager);
++ GdkDevice *keyboard = gdk_device_get_associated_device (pointer);
++#endif
++
++ gtk_grab_add (dock);
++
++#if GTK_CHECK_VERSION(3, 20, 0)
++ if (gdk_seat_grab (seat, window, GDK_SEAT_CAPABILITY_ALL, TRUE, NULL, NULL, NULL, NULL) != GDK_GRAB_SUCCESS)
++ goto fail_remove_grab;
++#else
++ if (gdk_device_grab (pointer, window, GDK_OWNERSHIP_WINDOW, TRUE, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
++ GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK, NULL, GDK_CURRENT_TIME) != GDK_GRAB_SUCCESS)
++ goto fail_remove_grab;
++
++ if (gdk_device_grab (keyboard, window, GDK_OWNERSHIP_WINDOW, TRUE, GDK_KEY_PRESS | GDK_KEY_RELEASE, NULL,
++ GDK_CURRENT_TIME) != GDK_GRAB_SUCCESS)
++ {
++ gdk_device_ungrab (pointer, GDK_CURRENT_TIME);
++ goto fail_remove_grab;
++ }
++#endif
++
++ return TRUE;
++
++fail_remove_grab:
++ gtk_grab_remove (dock);
++ return FALSE;
++}
++
++
++
++static void
++xfce_volume_button_ungrab_input (XfceVolumeButton *button)
++{
++ GtkWidget *dock = button->dock;
++ GdkDisplay *display = gtk_widget_get_display (dock);
++#if GTK_CHECK_VERSION(3, 20, 0)
++ GdkSeat *seat = gdk_display_get_default_seat (display);
++#else
++ GdkDeviceManager *device_manager = gdk_display_get_device_manager (display);
++ GdkDevice *pointer = gdk_device_manager_get_client_pointer (device_manager);
++ GdkDevice *keyboard = gdk_device_get_associated_device (pointer);
++#endif
++
++#if GTK_CHECK_VERSION(3, 20, 0)
++ gdk_seat_ungrab (seat);
++#else
++ gdk_device_ungrab (pointer, GDK_CURRENT_TIME);
++ gdk_device_ungrab (keyboard, GDK_CURRENT_TIME);
++#endif
++
++ gtk_grab_remove (dock);
++}
++
++
++
+ static void
+ xfce_volume_button_popup_dock (XfceVolumeButton *button)
+ {
+@@ -564,7 +633,7 @@ xfce_volume_button_popup_dock (XfceVolumeButton *button)
+ gint x;
+ gint y;
+ GtkPositionType position;
+- GdkDisplay *display;
++ GtkAllocation button_allocation;
+
+ /* Lazily create dock contents */
+ if (button->dock == NULL)
+@@ -591,12 +660,13 @@ xfce_volume_button_popup_dock (XfceVolumeButton *button)
+ }
+
+ /* Get size request of the dock */
+- gtk_widget_size_request (GTK_WIDGET (button->dock), &dock_requisition);
++ gtk_widget_get_preferred_size (GTK_WIDGET (button->dock), NULL, &dock_requisition);
+
+ /* Determine the absolute coordinates of the button widget */
+ gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (button)), &x, &y);
+- x += button_widget->allocation.x;
+- y += button_widget->allocation.y;
++ gtk_widget_get_allocation (button_widget, &button_allocation);
++ x += button_allocation.x;
++ y += button_allocation.y;
+
+ /* Determine the geometry of the monitor containing the window containing the button */
+ screen = gtk_widget_get_screen (button_widget);
+@@ -631,22 +701,22 @@ xfce_volume_button_popup_dock (XfceVolumeButton *button)
+ switch (position)
+ {
+ case GTK_POS_TOP:
+- x += (button_widget->allocation.width / 2) - (dock_requisition.width / 2);
++ x += (button_allocation.width / 2) - (dock_requisition.width / 2);
+ y -= dock_requisition.height;
+ break;
+ case GTK_POS_RIGHT:
+- x += button_widget->allocation.width;
+- y += (button_widget->allocation.height / 2) - (dock_requisition.height / 2);
++ x += button_allocation.width;
++ y += (button_allocation.height / 2) - (dock_requisition.height / 2);
+ break;
+ case GTK_POS_LEFT:
+ x -= dock_requisition.width;
+- y += (button_widget->allocation.height / 2) - (dock_requisition.height / 2);
++ y += (button_allocation.height / 2) - (dock_requisition.height / 2);
+ break;
+ case GTK_POS_BOTTOM:
+ default:
+ /* default to GTK_POS_BOTTOM */
+- x += (button_widget->allocation.width / 2) - (dock_requisition.width / 2);
+- y += button_widget->allocation.height;
++ x += (button_allocation.width / 2) - (dock_requisition.width / 2);
++ y += button_allocation.height;
+ break;
+ }
+
+@@ -666,25 +736,12 @@ xfce_volume_button_popup_dock (XfceVolumeButton *button)
+ gtk_widget_show (button->dock);
+
+ /* Grab keyboard and mouse, focus on the slider */
+- gtk_grab_add (button->dock);
+-
+- if (gdk_pointer_grab (gtk_widget_get_window (button->dock), TRUE,
+- GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK,
+- NULL, NULL, GDK_CURRENT_TIME) != GDK_GRAB_SUCCESS)
++ if (!xfce_volume_button_grab_input (button))
+ {
+- gtk_grab_remove (button->dock);
+ gtk_widget_hide (button->dock);
+ return;
+ }
+
+- if (gdk_keyboard_grab (gtk_widget_get_window (button->dock), TRUE, GDK_CURRENT_TIME) != GDK_GRAB_SUCCESS)
+- {
+- display = gtk_widget_get_display (button->dock);
+- gdk_display_pointer_ungrab (display, GDK_CURRENT_TIME);
+- gtk_grab_remove (button->dock);
+- gtk_widget_hide (button->dock);
+- return;
+- }
+ gtk_widget_grab_focus (button->dock);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+@@ -695,14 +752,9 @@ xfce_volume_button_popup_dock (XfceVolumeButton *button)
+ static void
+ xfce_volume_button_popdown_dock (XfceVolumeButton *button)
+ {
+- GdkDisplay *display;
+-
+ if (button->dock != NULL && gtk_widget_get_visible (button->dock))
+ {
+- display = gtk_widget_get_display (GTK_WIDGET (button->dock));
+- gdk_display_keyboard_ungrab (display, GDK_CURRENT_TIME);
+- gdk_display_pointer_ungrab (display, GDK_CURRENT_TIME);
+- gtk_grab_remove (button->dock);
++ xfce_volume_button_ungrab_input (button);
+
+ gtk_widget_hide (button->dock);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
+@@ -776,6 +828,9 @@ xfce_volume_button_scroll_event (GtkWidget *widget,
+ /* Decrease one step when scrolling down/left */
+ gtk_adjustment_set_value (GTK_ADJUSTMENT (button->adjustment), old_value - increment);
+ break;
++
++ case GDK_SCROLL_SMOOTH:
++ break;
+ }
+
+ new_value = gtk_adjustment_get_value (GTK_ADJUSTMENT (button->adjustment));
+@@ -923,7 +978,7 @@ xfce_volume_button_dock_key_release (XfceVolumeButton *button,
+ GtkWidget *widget)
+ {
+ /* Pop down on Escape */
+- if (event->keyval == GDK_Escape)
++ if (event->keyval == GDK_KEY_Escape)
+ {
+ xfce_volume_button_popdown_dock (button);
+ return TRUE;
+diff --git a/xfce4-mixer/Makefile.am b/xfce4-mixer/Makefile.am
+index 4af69e9..d7742df 100644
+--- a/xfce4-mixer/Makefile.am
++++ b/xfce4-mixer/Makefile.am
+@@ -5,6 +5,8 @@ bin_PROGRAMS = \
+
+ xfce4_mixer_SOURCES = \
+ main.c \
++ xfce-mixer-application.c \
++ xfce-mixer-application.h \
+ xfce-mixer-track.c \
+ xfce-mixer-track.h \
+ xfce-mixer-switch.c \
+@@ -23,13 +25,12 @@ xfce4_mixer_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
+ -DDATADIR=\"$(datadir)\" \
+- -DMIXER_DATADIR=\"$(pkgdatadir)\" \
++ -DMIXER_DATADIR=\"$(datadir)/xfce4/mixer\" \
+ -DG_LOG_DOMAIN=\"xfce4-mixer\"
+
+ xfce4_mixer_CFLAGS = \
+ $(GLIB_CFLAGS) \
+ $(GTK_CFLAGS) \
+- $(UNIQUE_CFLAGS) \
+ $(LIBXFCE4UTIL_CFLAGS) \
+ $(LIBXFCE4UI_CFLAGS) \
+ $(XFCONF_CFLAGS) \
+@@ -43,7 +44,6 @@ xfce4_mixer_LDFLAGS = \
+ $(GLIB_LIBS) \
+ $(GTHREAD_LIBS) \
+ $(GTK_LIBS) \
+- $(UNIQUE_LIBS) \
+ $(LIBXFCE4UTIL_LIBS) \
+ $(LIBXFCE4UI_LIBS) \
+ $(XFCONF_LIBS) \
+diff --git a/xfce4-mixer/main.c b/xfce4-mixer/main.c
+index 9e8417b..585c9e6 100644
+--- a/xfce4-mixer/main.c
++++ b/xfce4-mixer/main.c
+@@ -23,51 +23,11 @@
+ #include <config.h>
+ #endif
+
+-#ifdef HAVE_STDLIB_H
+-#include <stdlib.h>
+-#endif
+-
+-#include <gst/gst.h>
+-
+ #include <gtk/gtk.h>
+-#include <unique/unique.h>
+
+ #include <libxfce4util/libxfce4util.h>
+-#include <libxfce4ui/libxfce4ui.h>
+-#include <xfconf/xfconf.h>
+-
+-#include "libxfce4mixer/libxfce4mixer.h"
+-
+-#include "xfce-mixer-window.h"
+
+-
+-
+-static UniqueResponse
+-message_received (UniqueApp *app,
+- UniqueCommand command,
+- UniqueMessageData *message,
+- guint time_,
+- GtkWidget *window)
+-{
+- UniqueResponse response;
+-
+- switch (command)
+- {
+- case UNIQUE_ACTIVATE:
+- /* Move window to the screen the command was started on */
+- gtk_window_set_screen (GTK_WINDOW (window), unique_message_data_get_screen (message));
+- /* Bring window to the foreground */
+- gtk_window_present_with_time (GTK_WINDOW (window), time_);
+- response = UNIQUE_RESPONSE_OK;
+- break;
+- default:
+- /* Invalid command */
+- response = UNIQUE_RESPONSE_FAIL;
+- break;
+- }
+-
+- return response;
+-}
++#include "xfce-mixer-application.h"
+
+
+
+@@ -75,129 +35,20 @@ int
+ main (int argc,
+ char **argv)
+ {
+- UniqueApp *app;
+- GtkWidget *window;
+- GError *error = NULL;
+- gboolean debug_mode = FALSE;
+- gboolean show_version = FALSE;
+- GOptionContext *option_context;
+- GOptionEntry option_entries[] =
+- {
+- { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug_mode, N_("Enable debugging output"), NULL },
+- { "version", 'V', 0, G_OPTION_ARG_NONE, &show_version, N_("Show version and exit"), NULL },
+- { NULL, 0, 0, 0, NULL, NULL, NULL }
+- };
++ GApplication *app;
++ gint status;
+
+ /* Setup translation domain */
+ xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
+
+-#if !GLIB_CHECK_VERSION(2, 32, 0)
+- /* Initialize the threading system */
+- if (G_LIKELY (!g_thread_supported ()))
+- g_thread_init (NULL);
+-#endif
+-
+ /* Set application name */
+ g_set_application_name (_("Audio Mixer"));
+
+- /* Parse commandline options */
+- option_context = g_option_context_new ("- Adjust volume levels");
+- g_option_context_add_main_entries (option_context, option_entries, GETTEXT_PACKAGE);
+- g_option_context_add_group (option_context, gtk_get_option_group (FALSE));
+- g_option_context_add_group (option_context, gst_init_get_option_group ());
+- g_option_context_parse (option_context, &argc, &argv, &error);
+- g_option_context_free (option_context);
+- if (error != NULL)
+- {
+- g_printerr ("xfce4-mixer: %s\n", error->message);
+-
+- return EXIT_FAILURE;
+- }
+-
+- if (show_version)
+- {
+- g_print ("xfce4-mixer " VERSION "\n");
+-
+- return EXIT_SUCCESS;
+- }
+-
+- /* Initialize GTK+ fully */
+- gtk_init (NULL, NULL);
+-
+- /* Initialize Xfconf */
+- if (G_UNLIKELY (!xfconf_init (&error)))
+- {
+- if (G_LIKELY (error != NULL))
+- {
+- g_printerr (_("xfce4-mixer: Failed to initialize xfconf: %s\n"), error->message);
+- g_error_free (error);
+- }
+-
+- return EXIT_FAILURE;
+- }
+-
+- /* Initialize the mixer library */
+- xfce_mixer_init ();
+-
+- /* Use volume control icon for all mixer windows */
+- gtk_window_set_default_icon_name ("multimedia-volume-control");
+-
+- /* Warn users if there were no sound cards detected by GStreamer */
+- if (G_UNLIKELY (g_list_length (xfce_mixer_get_cards ()) <= 0))
+- {
+- xfce_dialog_show_error (NULL,
+- NULL,
+- _("GStreamer was unable to detect any sound devices. "
+- "Some sound system specific GStreamer packages may "
+- "be missing. It may also be a permissions problem."));
+-
+- return EXIT_FAILURE;
+- }
+-
+- /* Initialize debugging code */
+- xfce_mixer_debug_init (G_LOG_DOMAIN, debug_mode);
+-
+- xfce_mixer_debug ("xfce4-mixer version " VERSION " starting up");
+-
+- if (debug_mode)
+- xfce_mixer_dump_gst_data ();
+-
+- /* Create unique application */
+- app = unique_app_new ("org.xfce.xfce4-mixer", NULL);
+- if (unique_app_is_running (app))
+- {
+- unique_app_send_message (app, UNIQUE_ACTIVATE, NULL);
+-
+- g_object_unref (app);
+- }
+- else
+- {
+- /* Create the mixer window */
+- window = xfce_mixer_window_new ();
+-
+- /* Display the mixer window */
+- gtk_widget_show (window);
+-
+- /* Watch mixer window */
+- unique_app_watch_window (app, GTK_WINDOW (window));
+-
+- /* Handle messages */
+- g_signal_connect (app, "message-received", G_CALLBACK (message_received), window);
+-
+- /* Enter the GTK+ main loop */
+- gtk_main ();
+-
+- g_object_unref (app);
+-
+- /* Destroy the window */
+- gtk_widget_destroy (window);
+- }
++ app = xfce_mixer_application_new ();
+
+- /* Shutdown the mixer library */
+- xfce_mixer_shutdown ();
++ status = g_application_run (app, argc, argv);
+
+- /* Shutdown Xfconf */
+- xfconf_shutdown ();
++ g_object_unref (app);
+
+- return EXIT_SUCCESS;
++ return status;
+ }
+diff --git a/xfce4-mixer/xfce-mixer-application.c b/xfce4-mixer/xfce-mixer-application.c
+new file mode 100644
+index 0000000..1559675
+--- /dev/null
++++ b/xfce4-mixer/xfce-mixer-application.c
+@@ -0,0 +1,232 @@
++/* vi:set expandtab sw=2 sts=2: */
++/*-
++ * Copyright (c) 2008 Jannis Pohlmann <jannis@xfce.org>
++ * Copyright (c) 2012 Guido Berhoerster <guido+xfce@berhoerster.name>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
++ * Boston, MA 02110-1301, USA.
++ */
++
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
++
++#ifdef HAVE_STDLIB_H
++#include <stdlib.h>
++#endif
++
++#include <gst/gst.h>
++#include <gtk/gtk.h>
++
++#include <libxfce4util/libxfce4util.h>
++#include <libxfce4ui/libxfce4ui.h>
++#include <xfconf/xfconf.h>
++
++#include "libxfce4mixer/libxfce4mixer.h"
++
++#include "xfce-mixer-application.h"
++#include "xfce-mixer-window.h"
++
++
++
++static void xfce_mixer_application_dispose (GObject *object);
++static void xfce_mixer_application_finalize (GObject *object);
++static void xfce_mixer_application_startup (GApplication *app);
++static void xfce_mixer_application_activate (GApplication *app);
++static void xfce_mixer_application_shutdown (GApplication *app);
++static gint xfce_mixer_application_handle_local_options (GApplication *app,
++ GVariantDict *options,
++ gpointer user_data);
++
++
++
++struct _XfceMixerApplicationClass
++{
++ GtkApplicationClass __parent__;
++};
++
++struct _XfceMixerApplication
++{
++ GtkApplication __parent__;
++
++ GtkWidget *main_window;
++};
++
++
++
++G_DEFINE_TYPE (XfceMixerApplication, xfce_mixer_application, GTK_TYPE_APPLICATION)
++
++
++
++static gboolean debug_mode = FALSE;
++static gboolean show_version = FALSE;
++
++static GOptionEntry option_entries[] =
++{
++ { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug_mode, N_("Enable debugging output"), NULL },
++ { "version", 'V', 0, G_OPTION_ARG_NONE, &show_version, N_("Show version and exit"), NULL },
++ { NULL, 0, 0, 0, NULL, NULL, NULL }
++};
++
++
++
++static void
++xfce_mixer_application_class_init (XfceMixerApplicationClass *klass)
++{
++ GObjectClass *gobject_class;
++ GApplicationClass *g_application_class;
++
++ gobject_class = G_OBJECT_CLASS (klass);
++ gobject_class->dispose = xfce_mixer_application_dispose;
++ gobject_class->finalize = xfce_mixer_application_finalize;
++
++ g_application_class = G_APPLICATION_CLASS (klass);
++ g_application_class->startup = xfce_mixer_application_startup;
++ g_application_class->activate = xfce_mixer_application_activate;
++ g_application_class->shutdown = xfce_mixer_application_shutdown;
++}
++
++
++
++static void
++xfce_mixer_application_init (XfceMixerApplication *app)
++{
++ app->main_window = NULL;
++
++ g_application_add_main_option_entries (G_APPLICATION (app), option_entries);
++ g_application_add_option_group (G_APPLICATION (app), gst_init_get_option_group ());
++
++ g_signal_connect (app, "handle-local-options", G_CALLBACK (xfce_mixer_application_handle_local_options), NULL);
++}
++
++
++
++static void
++xfce_mixer_application_dispose (GObject *object)
++{
++ (*G_OBJECT_CLASS (xfce_mixer_application_parent_class)->dispose) (object);
++}
++
++
++
++static void
++xfce_mixer_application_finalize (GObject *object)
++{
++ (*G_OBJECT_CLASS (xfce_mixer_application_parent_class)->finalize) (object);
++}
++
++
++
++static void
++xfce_mixer_application_startup (GApplication *app)
++{
++ GError *error = NULL;
++
++ (*G_APPLICATION_CLASS (xfce_mixer_application_parent_class)->startup) (app);
++
++ /* Initialize Xfconf */
++ if (G_UNLIKELY (!xfconf_init (&error)))
++ {
++ if (G_LIKELY (error != NULL))
++ {
++ g_printerr (_("xfce4-mixer: Failed to initialize xfconf: %s\n"), error->message);
++ g_error_free (error);
++ }
++
++ exit (EXIT_FAILURE);
++ }
++
++ /* Initialize the mixer library */
++ xfce_mixer_init ();
++
++ /* Use volume control icon for all mixer windows */
++ gtk_window_set_default_icon_name ("multimedia-volume-control");
++
++ /* Warn users if there were no sound cards detected by GStreamer */
++ if (G_UNLIKELY (g_list_length (xfce_mixer_get_cards ()) <= 0))
++ {
++ xfce_dialog_show_error (NULL,
++ NULL,
++ _("GStreamer was unable to detect any sound devices. "
++ "Some sound system specific GStreamer packages may "
++ "be missing. It may also be a permissions problem."));
++ exit (EXIT_FAILURE);
++ }
++
++ /* Initialize debugging code */
++ xfce_mixer_debug_init (G_LOG_DOMAIN, debug_mode);
++
++ xfce_mixer_debug ("xfce4-mixer version " VERSION " starting up");
++
++ if (debug_mode)
++ xfce_mixer_dump_gst_data ();
++}
++
++
++
++static void
++xfce_mixer_application_activate (GApplication *app_)
++{
++ XfceMixerApplication *app = XFCE_MIXER_APPLICATION (app_);
++
++ /* Create the mixer window */
++ if (app->main_window == NULL)
++ app->main_window = xfce_mixer_window_new (app_);
++
++ /* Display the mixer window */
++ gtk_window_present (GTK_WINDOW (app->main_window));
++}
++
++
++
++static void
++xfce_mixer_application_shutdown (GApplication *app)
++{
++ /* Shutdown the mixer library */
++ xfce_mixer_shutdown ();
++
++ /* Shutdown Xfconf */
++ xfconf_shutdown ();
++
++ (*G_APPLICATION_CLASS (xfce_mixer_application_parent_class)->shutdown) (app);
++}
++
++
++
++static gint
++xfce_mixer_application_handle_local_options (GApplication *app,
++ GVariantDict *options,
++ gpointer user_data)
++{
++ if (show_version)
++ {
++ g_print ("xfce4-mixer " VERSION "\n");
++ return EXIT_SUCCESS;
++ }
++
++ return -1;
++}
++
++
++
++GApplication*
++xfce_mixer_application_new (void)
++{
++ XfceMixerApplication *app;
++
++ app = g_object_new (TYPE_XFCE_MIXER_APPLICATION, "application-id", "org.xfce.xfce4-mixer", NULL);
++
++ return G_APPLICATION (app);
++}
+diff --git a/xfce4-mixer/xfce-mixer-application.h b/xfce4-mixer/xfce-mixer-application.h
+new file mode 100644
+index 0000000..e4a5534
+--- /dev/null
++++ b/xfce4-mixer/xfce-mixer-application.h
+@@ -0,0 +1,42 @@
++/* vi:set expandtab sw=2 sts=2: */
++/*-
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
++ * Boston, MA 02110-1301, USA.
++ */
++
++#ifndef __XFCE_MIXER_APPLICATION_H__
++#define __XFCE_MIXER_APPLICATION_H__
++
++#include <gtk/gtk.h>
++
++G_BEGIN_DECLS
++
++typedef struct _XfceMixerApplicationClass XfceMixerApplicationClass;
++typedef struct _XfceMixerApplication XfceMixerApplication;
++
++#define TYPE_XFCE_MIXER_APPLICATION (xfce_mixer_application_get_type ())
++#define XFCE_MIXER_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_XFCE_MIXER_APPLICATION, XfceMixerApplication))
++#define XFCE_MIXER_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_XFCE_MIXER_APPLICATION, XfceMixerApplicationClass))
++#define IS_XFCE_MIXER_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_XFCE_MIXER_APPLICATION))
++#define IS_XFCE_MIXER_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_XFCE_MIXER_APPLICATION))
++#define XFCE_MIXER_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_XFCE_MIXER_APPLICATION, XfceMixerApplicationClass))
++
++GType xfce_mixer_application_get_type (void) G_GNUC_CONST;
++
++GApplication *xfce_mixer_application_new (void);
++
++G_END_DECLS
++
++#endif /* !__XFCE_MIXER_APPLICATION_H__ */
+diff --git a/xfce4-mixer/xfce-mixer-container.c b/xfce4-mixer/xfce-mixer-container.c
+index d59240a..560ee66 100644
+--- a/xfce4-mixer/xfce-mixer-container.c
++++ b/xfce4-mixer/xfce-mixer-container.c
+@@ -216,15 +216,12 @@ xfce_mixer_container_create_contents (XfceMixerContainer *mixer_container)
+ GstMixerTrack *track;
+ const GList *iter;
+ const gchar *titles[4] = { N_("_Playback"), N_("C_apture"), N_("S_witches"), N_("_Options") };
+- GtkWidget *label_alignment;
+- GtkWidget *option_alignment;
+ GtkWidget *track_widget;
+ GtkWidget *track_label_widget;
+ GtkWidget *labels[4];
+ GtkWidget *scrollwins[4];
+ GtkWidget *views[4];
+ GtkWidget *last_separator[4] = { NULL, NULL, NULL, NULL };
+- GtkWidget *alignment;
+ GtkWidget *vbox;
+ GtkWidget *label1;
+ GtkWidget *label2;
+@@ -248,16 +245,9 @@ xfce_mixer_container_create_contents (XfceMixerContainer *mixer_container)
+ gtk_container_set_border_width (GTK_CONTAINER (scrollwins[i]), 6);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwins[i]), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+- if (i < 2)
+- views[i] = gtk_table_new (1, 2, FALSE);
+- else
+- views[i] = gtk_table_new (2, 1, FALSE);
+-
+- gtk_table_set_col_spacings (GTK_TABLE (views[i]), 12);
+- gtk_table_set_row_spacings (GTK_TABLE (views[i]), 6);
+-
+- gtk_container_set_border_width (GTK_CONTAINER (views[i]), 6);
+- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrollwins[i]), views[i]);
++ views[i] = gtk_grid_new ();
++ g_object_set (G_OBJECT (views[i]), "row-spacing", 6, "column-spacing", 12, "border-width", 6, NULL);
++ gtk_container_add (GTK_CONTAINER (scrollwins[i]), views[i]);
+ gtk_viewport_set_shadow_type (GTK_VIEWPORT (gtk_bin_get_child (GTK_BIN (scrollwins[i]))), GTK_SHADOW_NONE);
+ gtk_widget_show (views[i]);
+ gtk_widget_show (scrollwins[i]);
+@@ -283,19 +273,17 @@ xfce_mixer_container_create_contents (XfceMixerContainer *mixer_container)
+ case XFCE_MIXER_TRACK_TYPE_PLAYBACK:
+ /* Create a regular volume control for this track */
+ track_label_widget = gtk_label_new (track_label);
+- gtk_table_attach (GTK_TABLE (views[0]), track_label_widget,
+- num_children[0], num_children[0] + 1, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
++ gtk_grid_attach (GTK_GRID (views[0]), track_label_widget, num_children[0], 0, 1, 1);
+ gtk_widget_show (track_label_widget);
+ track_widget = xfce_mixer_track_new (mixer_container->card, track);
+- gtk_table_attach (GTK_TABLE (views[0]), track_widget,
+- num_children[0], num_children[0] + 1, 1, 2, GTK_SHRINK, GTK_FILL|GTK_EXPAND, 0, 0);
++ g_object_set (G_OBJECT (track_widget), "valign", GTK_ALIGN_FILL, "vexpand", TRUE, NULL);
++ gtk_grid_attach (GTK_GRID (views[0]), track_widget, num_children[0], 1, 1, 1);
+ gtk_widget_show (track_widget);
+ num_children[0]++;
+
+ /* Append a separator. The last one will be destroyed later */
+- last_separator[0] = gtk_vseparator_new ();
+- gtk_table_attach (GTK_TABLE (views[0]), last_separator[0],
+- num_children[0], num_children[0] + 1, 0, 2, GTK_SHRINK, GTK_FILL|GTK_EXPAND, 0, 0);
++ last_separator[0] = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
++ gtk_grid_attach (GTK_GRID (views[0]), last_separator[0], num_children[0], 0, 1, 2);
+ gtk_widget_show (last_separator[0]);
+ num_children[0]++;
+
+@@ -306,19 +294,17 @@ xfce_mixer_container_create_contents (XfceMixerContainer *mixer_container)
+ case XFCE_MIXER_TRACK_TYPE_CAPTURE:
+ /* Create a regular volume control for this track */
+ track_label_widget = gtk_label_new (track_label);
+- gtk_table_attach (GTK_TABLE (views[1]), track_label_widget,
+- num_children[1], num_children[1] + 1, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
++ gtk_grid_attach (GTK_GRID (views[1]), track_label_widget, num_children[1], 0, 1, 1);
+ gtk_widget_show (track_label_widget);
+ track_widget = xfce_mixer_track_new (mixer_container->card, track);
+- gtk_table_attach (GTK_TABLE (views[1]), track_widget,
+- num_children[1], num_children[1] + 1, 1, 2, GTK_SHRINK, GTK_FILL|GTK_EXPAND, 0, 0);
++ g_object_set (G_OBJECT (track_widget), "valign", GTK_ALIGN_FILL, "vexpand", TRUE, NULL);
++ gtk_grid_attach (GTK_GRID (views[1]), track_widget, num_children[1], 1, 1, 1);
+ gtk_widget_show (track_widget);
+ num_children[1]++;
+
+ /* Append a separator. The last one will be destroyed later */
+- last_separator[1] = gtk_vseparator_new ();
+- gtk_table_attach (GTK_TABLE (views[1]), last_separator[1],
+- num_children[1], num_children[1] + 1, 0, 2, GTK_SHRINK, GTK_FILL|GTK_EXPAND, 0, 0);
++ last_separator[1] = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
++ gtk_grid_attach (GTK_GRID (views[1]), last_separator[1], num_children[1], 0, 1, 2);
+ gtk_widget_show (last_separator[1]);
+ num_children[1]++;
+
+@@ -328,8 +314,8 @@ xfce_mixer_container_create_contents (XfceMixerContainer *mixer_container)
+
+ case XFCE_MIXER_TRACK_TYPE_SWITCH:
+ track_widget = xfce_mixer_switch_new (mixer_container->card, track);
+- gtk_table_attach (GTK_TABLE (views[2]), track_widget,
+- 0, 1, num_children[2], num_children[2] + 1, GTK_FILL|GTK_EXPAND, GTK_SHRINK, 0, 0);
++ g_object_set (G_OBJECT (track_widget), "halign", GTK_ALIGN_FILL, "hexpand", TRUE, NULL);
++ gtk_grid_attach (GTK_GRID (views[2]), track_widget, 0, num_children[2], 1, 1);
+ gtk_widget_show (track_widget);
+
+ num_children[2]++;
+@@ -339,24 +325,16 @@ xfce_mixer_container_create_contents (XfceMixerContainer *mixer_container)
+ break;
+
+ case XFCE_MIXER_TRACK_TYPE_OPTIONS:
+- label_alignment = gtk_alignment_new (0, 0, 0, 0);
+- gtk_table_attach (GTK_TABLE (views[3]), label_alignment,
+- 0, 1, num_children[3], num_children[3] + 1, GTK_FILL, GTK_SHRINK, 0, 0);
+- gtk_widget_show (label_alignment);
+-
+ option_track_label = g_strdup_printf ("%s:", track_label);
+ track_label_widget = gtk_label_new (option_track_label);
+- gtk_container_add (GTK_CONTAINER (label_alignment), track_label_widget);
++ g_object_set (G_OBJECT (track_label_widget), "halign", GTK_ALIGN_FILL, NULL);
++ gtk_grid_attach (GTK_GRID (views[3]), track_label_widget, 0, num_children[3], 1, 1);
+ gtk_widget_show (track_label_widget);
+ g_free (option_track_label);
+
+- option_alignment = gtk_alignment_new (0, 0, 1.0f, 0);
+- gtk_table_attach (GTK_TABLE (views[3]), option_alignment,
+- 1, 2, num_children[3], num_children[3] + 1, GTK_FILL|GTK_EXPAND, GTK_SHRINK, 0, 0);
+- gtk_widget_show (option_alignment);
+-
+ track_widget = xfce_mixer_option_new (mixer_container->card, track);
+- gtk_container_add (GTK_CONTAINER (option_alignment), track_widget);
++ g_object_set (G_OBJECT (track_widget), "halign", GTK_ALIGN_FILL, "hexpand", TRUE, NULL);
++ gtk_grid_attach (GTK_GRID (views[3]), track_widget, 1, num_children[3], 1, 1);
+ gtk_widget_show (track_widget);
+
+ num_children[3]++;
+@@ -390,30 +368,24 @@ xfce_mixer_container_create_contents (XfceMixerContainer *mixer_container)
+ label1 = gtk_label_new (_("No controls visible"));
+ gtk_widget_show (label1);
+
+- alignment = gtk_alignment_new (0.5, 0.5, 0, 0);
+- gtk_widget_show (alignment);
+-
+- vbox = gtk_vbox_new (6, FALSE);
+- gtk_container_add (GTK_CONTAINER (alignment), vbox);
++ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
++ g_object_set (G_OBJECT (vbox), "halign", GTK_ALIGN_CENTER, "hexpand", TRUE, "valign", GTK_ALIGN_CENTER, "vexpand", TRUE,
++ "border-width", 6, NULL);
+ gtk_widget_show (vbox);
+
+ label2 = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label2), _("<span weight=\"bold\" size=\"larger\">No controls visible</span>"));
+- gtk_label_set_max_width_chars (GTK_LABEL (label2), 80);
+- gtk_label_set_line_wrap (GTK_LABEL (label2), TRUE);
+- gtk_misc_set_alignment (GTK_MISC (label2), 0.0, 0.5);
++ g_object_set (G_OBJECT (label2), "max-width-chars", 80, "xalign", 0.0, "wrap", TRUE, NULL);
+ gtk_box_pack_start (GTK_BOX (vbox), label2, FALSE, TRUE, 0);
+ gtk_widget_show (label2);
+
+ label3 = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label3), _("In order to toggle the visibility of mixer controls, open the <b>\"Select Controls\"</b> dialog."));
+- gtk_label_set_max_width_chars (GTK_LABEL (label3), 80);
+- gtk_label_set_line_wrap (GTK_LABEL (label3), TRUE);
+- gtk_misc_set_alignment (GTK_MISC (label3), 0.0, 0.5);
++ g_object_set (G_OBJECT (label3), "max-width-chars", 80, "xalign", 0.0, "wrap", TRUE, NULL);
+ gtk_box_pack_start (GTK_BOX (vbox), label3, FALSE, TRUE, 0);
+ gtk_widget_show (label3);
+
+- gtk_notebook_append_page (GTK_NOTEBOOK (mixer_container), alignment, label1);
++ gtk_notebook_append_page (GTK_NOTEBOOK (mixer_container), vbox, label1);
+ }
+
+ g_object_unref (preferences);
+diff --git a/xfce4-mixer/xfce-mixer-controls-dialog.c b/xfce4-mixer/xfce-mixer-controls-dialog.c
+index dd79a77..92886fb 100644
+--- a/xfce4-mixer/xfce-mixer-controls-dialog.c
++++ b/xfce4-mixer/xfce-mixer-controls-dialog.c
+@@ -119,7 +119,9 @@ xfce_mixer_controls_dialog_init (XfceMixerControlsDialog *dialog)
+
+ xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dialog), _("Select which controls should be visible"));
+
+- button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
++ button = gtk_button_new_with_mnemonic (_("_Close"));
++ gtk_button_set_image (GTK_BUTTON (button),
++ gtk_image_new_from_icon_name ("window-close", GTK_ICON_SIZE_BUTTON));
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_CLOSE);
+ gtk_widget_show (button);
+ }
+@@ -191,14 +193,15 @@ xfce_mixer_controls_dialog_create_contents (XfceMixerControlsDialog *dialog)
+ dialog->store = gtk_list_store_new (2, G_TYPE_BOOLEAN, G_TYPE_STRING);
+
+ dialog->frame = gtk_frame_new (NULL);
+- gtk_container_set_border_width (GTK_CONTAINER (dialog->frame), 6);
++ g_object_set (G_OBJECT (dialog->frame), "margin-top", 6, "margin-bottom", 6, NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (dialog->frame), GTK_SHADOW_NONE);
+- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog->frame);
++ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), dialog->frame);
+ gtk_widget_show (dialog->frame);
+
+ scrollwin = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrollwin), GTK_SHADOW_IN);
++ g_object_set (G_OBJECT (scrollwin), "halign", GTK_ALIGN_FILL, "hexpand", TRUE, "valign", GTK_ALIGN_FILL, "vexpand", TRUE, NULL);
+ gtk_container_add (GTK_CONTAINER (dialog->frame), scrollwin);
+ gtk_widget_show (scrollwin);
+
+diff --git a/xfce4-mixer/xfce-mixer-option.c b/xfce4-mixer/xfce-mixer-option.c
+index d16b766..969baad 100644
+--- a/xfce4-mixer/xfce-mixer-option.c
++++ b/xfce4-mixer/xfce-mixer-option.c
+@@ -189,15 +189,15 @@ static void
+ xfce_mixer_option_changed (GtkComboBox *combo,
+ XfceMixerOption *option)
+ {
+- gchar *active_option;
++ GtkTreeIter iter;
++ gchar *active_option;
+
+ if (G_UNLIKELY (option->ignore_signals))
+ return;
+
+- active_option = gtk_combo_box_get_active_text (combo);
+-
+- if (G_LIKELY (active_option != NULL))
++ if (G_LIKELY (gtk_combo_box_get_active_iter (combo, &iter)))
+ {
++ gtk_tree_model_get (GTK_TREE_MODEL (option->list_store), &iter, OPTION_COLUMN, &active_option, -1);
+ gst_mixer_set_option (GST_MIXER (option->card), GST_MIXER_OPTIONS (option->track),
+ active_option);
+ g_free (active_option);
+diff --git a/xfce4-mixer/xfce-mixer-track.c b/xfce4-mixer/xfce-mixer-track.c
+index a7442ed..831d127 100644
+--- a/xfce4-mixer/xfce-mixer-track.c
++++ b/xfce4-mixer/xfce-mixer-track.c
+@@ -45,8 +45,8 @@
+
+ static void xfce_mixer_track_dispose (GObject *object);
+ static void xfce_mixer_track_finalize (GObject *object);
+-static gboolean xfce_mixer_track_lock_button_line_expose_event (GtkWidget *widget,
+- GdkEventExpose *event,
++static gboolean xfce_mixer_track_lock_button_line_draw (GtkWidget *widget,
++ cairo_t *cr,
+ gpointer user_data);
+ static void xfce_mixer_track_create_contents (XfceMixerTrack *track);
+ static void xfce_mixer_track_fader_changed (GtkRange *range,
+@@ -83,7 +83,7 @@ struct _XfceMixerTrack
+
+
+
+-G_DEFINE_TYPE (XfceMixerTrack, xfce_mixer_track, GTK_TYPE_VBOX)
++G_DEFINE_TYPE (XfceMixerTrack, xfce_mixer_track, GTK_TYPE_BOX)
+
+
+
+@@ -138,7 +138,7 @@ xfce_mixer_track_new (GstElement *card,
+ g_return_val_if_fail (GST_IS_MIXER (card), NULL);
+ g_return_val_if_fail (GST_IS_MIXER_TRACK (gst_track), NULL);
+
+- track = g_object_new (TYPE_XFCE_MIXER_TRACK, NULL);
++ track = g_object_new (TYPE_XFCE_MIXER_TRACK, "orientation", GTK_ORIENTATION_VERTICAL, NULL);
+ track->card = card;
+ track->gst_track = gst_track;
+
+@@ -150,32 +150,27 @@ xfce_mixer_track_new (GstElement *card,
+
+
+ static gboolean
+-xfce_mixer_track_lock_button_line_expose_event (GtkWidget *widget,
+- GdkEventExpose *event,
+- gpointer user_data)
++xfce_mixer_track_lock_button_line_draw (GtkWidget *widget,
++ cairo_t *cr,
++ gpointer user_data)
+ {
+ GtkPositionType position = GPOINTER_TO_INT (user_data);
+ GtkAllocation allocation;
+- cairo_t *cr;
+- GtkStyle *style = gtk_widget_get_style (widget);
++ GtkStyleContext *style_context = gtk_widget_get_style_context (widget);
+ GdkPoint points[3];
+ double line_width = 2.0;
+-
+- cr = gdk_cairo_create (gtk_widget_get_window (widget));
++ GdkRGBA fg_color;
+
+ gtk_widget_get_allocation (widget, &allocation);
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+ position = (position == GTK_POS_LEFT) ? GTK_POS_RIGHT : GTK_POS_LEFT;
+
+- /* Only refresh regions where it is necessary */
+- gdk_cairo_region (cr, event->region);
+- cairo_clip (cr);
+-
+ /*
+ * Draw an L-shaped line from the right/left center to the top middle of the
+ * allocation
+ */
+- gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
++ gtk_style_context_get_color (style_context, GTK_STATE_FLAG_NORMAL, &fg_color);
++ gdk_cairo_set_source_rgba (cr, &fg_color);
+ cairo_set_line_width(cr, line_width);
+ if (position == GTK_POS_RIGHT)
+ {
+@@ -200,8 +195,6 @@ xfce_mixer_track_lock_button_line_expose_event (GtkWidget *widget,
+ cairo_line_to (cr, points[2].x, points[2].y);
+ cairo_stroke (cr);
+
+- cairo_destroy (cr);
+-
+ return TRUE;
+ }
+
+@@ -216,7 +209,6 @@ xfce_mixer_track_create_contents (XfceMixerTrack *track)
+ const gchar *track_label;
+ gchar *tooltip_text;
+ gdouble step;
+- GtkWidget *faders_alignment;
+ GtkWidget *faders_vbox;
+ GtkWidget *faders_hbox;
+ GtkWidget *lock_button_hbox;
+@@ -224,7 +216,6 @@ xfce_mixer_track_create_contents (XfceMixerTrack *track)
+ GtkWidget *lock_button_line1;
+ GtkWidget *lock_button_line2;
+ GtkWidget *image;
+- GtkWidget *buttons_alignment;
+ GtkWidget *buttons_hbox;
+ GtkRequisition lock_button_hbox_requisition;
+
+@@ -239,15 +230,12 @@ xfce_mixer_track_create_contents (XfceMixerTrack *track)
+ gtk_box_set_spacing (GTK_BOX (track), 6);
+
+ /* Center and do not expand faders and lock button */
+- faders_alignment = gtk_alignment_new (0.5, 1.0, 0, 1.0);
+- gtk_box_pack_start (GTK_BOX (track), faders_alignment, TRUE, TRUE, 0);
+- gtk_widget_show (faders_alignment);
+-
+- faders_vbox = gtk_vbox_new (FALSE, 6);
+- gtk_container_add (GTK_CONTAINER (faders_alignment), faders_vbox);
++ faders_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
++ g_object_set (G_OBJECT (faders_vbox), "halign", GTK_ALIGN_CENTER, "valign", GTK_ALIGN_FILL, "vexpand", TRUE, NULL);
++ gtk_box_pack_start (GTK_BOX (track), faders_vbox, TRUE, TRUE, 0);
+ gtk_widget_show (faders_vbox);
+
+- faders_hbox = gtk_hbox_new (TRUE, 6);
++ faders_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_box_pack_start (GTK_BOX (faders_vbox), faders_hbox, TRUE, TRUE, 0);
+ gtk_widget_show (faders_hbox);
+
+@@ -256,7 +244,7 @@ xfce_mixer_track_create_contents (XfceMixerTrack *track)
+ {
+ tooltip_text = g_strdup_printf (_("Volume of channel %d on %s"), channel, track_label);
+
+- fader = gtk_vscale_new_with_range (track->gst_track->min_volume, track->gst_track->max_volume, step);
++ fader = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL, track->gst_track->min_volume, track->gst_track->max_volume, step);
+ gtk_scale_set_draw_value (GTK_SCALE (fader), FALSE);
+ gtk_range_set_inverted (GTK_RANGE (fader), TRUE);
+ gtk_range_set_value (GTK_RANGE (fader), volumes[channel]);
+@@ -278,7 +266,7 @@ xfce_mixer_track_create_contents (XfceMixerTrack *track)
+ }
+
+ /* Create lock button with lines */
+- lock_button_hbox = gtk_hbox_new (FALSE, 0);
++ lock_button_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_pack_start (GTK_BOX (faders_vbox), lock_button_hbox, FALSE, FALSE, 0);
+ gtk_widget_show (lock_button_hbox);
+
+@@ -286,7 +274,7 @@ xfce_mixer_track_create_contents (XfceMixerTrack *track)
+ lock_button_line1 = gtk_drawing_area_new ();
+ gtk_widget_set_size_request (lock_button_line1, 12, 8);
+ gtk_box_pack_start (GTK_BOX (lock_button_hbox), lock_button_line1, TRUE, TRUE, 0);
+- g_signal_connect (G_OBJECT (lock_button_line1), "expose-event", G_CALLBACK (xfce_mixer_track_lock_button_line_expose_event), GINT_TO_POINTER (GTK_POS_LEFT));
++ g_signal_connect (G_OBJECT (lock_button_line1), "draw", G_CALLBACK (xfce_mixer_track_lock_button_line_draw), GINT_TO_POINTER (GTK_POS_LEFT));
+ gtk_widget_show (lock_button_line1);
+
+ /* Lock button */
+@@ -309,7 +297,7 @@ xfce_mixer_track_create_contents (XfceMixerTrack *track)
+ lock_button_line2 = gtk_drawing_area_new ();
+ gtk_widget_set_size_request (lock_button_line2, 12, 8);
+ gtk_box_pack_start (GTK_BOX (lock_button_hbox), lock_button_line2, TRUE, TRUE, 0);
+- g_signal_connect (G_OBJECT (lock_button_line2), "expose-event", G_CALLBACK (xfce_mixer_track_lock_button_line_expose_event), GINT_TO_POINTER (GTK_POS_RIGHT));
++ g_signal_connect (G_OBJECT (lock_button_line2), "draw", G_CALLBACK (xfce_mixer_track_lock_button_line_draw), GINT_TO_POINTER (GTK_POS_RIGHT));
+ gtk_widget_show (lock_button_line2);
+
+ /*
+@@ -318,20 +306,17 @@ xfce_mixer_track_create_contents (XfceMixerTrack *track)
+ */
+ if (track->gst_track->num_channels < 2)
+ {
+- gtk_widget_size_request (lock_button_hbox, &lock_button_hbox_requisition);
++ gtk_widget_get_preferred_size (lock_button_hbox, NULL, &lock_button_hbox_requisition);
+ gtk_widget_destroy (lock_button_hbox);
+- lock_button_hbox = gtk_hbox_new (FALSE, 0);
++ lock_button_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_widget_set_size_request (lock_button_hbox, lock_button_hbox_requisition.width, lock_button_hbox_requisition.height);
+ gtk_box_pack_start (GTK_BOX (faders_vbox), lock_button_hbox, FALSE, FALSE, 0);
+ gtk_widget_show (lock_button_hbox);
+ }
+
+- buttons_alignment = gtk_alignment_new (0.5, 1.0, 0, 0);
+- gtk_box_pack_start (GTK_BOX (track), buttons_alignment, FALSE, FALSE, 0);
+- gtk_widget_show (buttons_alignment);
+-
+- buttons_hbox = gtk_hbox_new (FALSE, 12);
+- gtk_container_add (GTK_CONTAINER (buttons_alignment), buttons_hbox);
++ buttons_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
++ g_object_set (G_OBJECT (buttons_hbox), "halign", GTK_ALIGN_CENTER, "valign", GTK_ALIGN_END, NULL);
++ gtk_box_pack_start (GTK_BOX (track), buttons_hbox, FALSE, FALSE, 0);
+ gtk_widget_show (buttons_hbox);
+
+ /* Mute button for playback tracks */
+diff --git a/xfce4-mixer/xfce-mixer-window.c b/xfce4-mixer/xfce-mixer-window.c
+index 7f9a9e9..248236b 100644
+--- a/xfce4-mixer/xfce-mixer-window.c
++++ b/xfce4-mixer/xfce-mixer-window.c
+@@ -40,22 +40,26 @@
+
+ static void xfce_mixer_window_dispose (GObject *object);
+ static void xfce_mixer_window_finalize (GObject *object);
++static void xfce_mixer_window_size_allocate (GtkWidget *widget,
++ GtkAllocation *allocation);
++static gboolean xfce_mixer_window_state_event (GtkWidget *widget,
++ GdkEventWindowState *event);
++static void xfce_mixer_window_destroy (GtkWidget *widget);
+ static void xfce_mixer_window_soundcard_changed (XfceMixerCardCombo *combo,
+ GstElement *card,
+ XfceMixerWindow *window);
+ static void xfce_mixer_window_soundcard_property_changed (XfceMixerWindow *window,
+ GParamSpec *pspec,
+ GObject *object);
+-static void xfce_mixer_window_action_select_controls (GtkAction *action,
+- XfceMixerWindow *window);
++static void xfce_mixer_window_action_select_controls (GSimpleAction *action,
++ GVariant *parameter,
++ gpointer user_data);
+ static void xfce_mixer_window_controls_property_changed (XfceMixerWindow *window,
+ GParamSpec *pspec,
+ GObject *object);
+-static void xfce_mixer_window_close (GtkAction *action,
+- XfceMixerWindow *window);
+-static gboolean xfce_mixer_window_closed (GtkWidget *window,
+- GdkEvent *event,
+- XfceMixerWindow *mixer_window);
++static void xfce_mixer_window_close (GSimpleAction *action,
++ GVariant *parameter,
++ gpointer user_data);
+ static void xfce_mixer_window_update_contents (XfceMixerWindow *window);
+
+
+@@ -71,7 +75,11 @@ struct _XfceMixerWindow
+
+ XfceMixerPreferences *preferences;
+
+- GtkActionGroup *action_group;
++ /* Current window state */
++ gint current_width;
++ gint current_height;
++ gboolean is_maximized;
++ gboolean is_fullscreen;
+
+ GtkWidget *soundcard_combo;
+
+@@ -86,12 +94,10 @@ struct _XfceMixerWindow
+
+
+
+-static const GtkActionEntry action_entries[] =
++static const GActionEntry action_entries[] =
+ {
+- { "quit", GTK_STOCK_QUIT, N_ ("_Quit"), "<Control>q", N_ ("Exit the mixer"),
+- G_CALLBACK (xfce_mixer_window_close) },
+- { "select-controls", NULL, N_ ("_Select Controls..."), "<Control>s", N_ ("Select which controls are displayed"),
+- G_CALLBACK (xfce_mixer_window_action_select_controls) },
++ { "quit", &xfce_mixer_window_close, NULL, NULL, NULL },
++ { "select-controls", &xfce_mixer_window_action_select_controls, NULL, NULL, NULL },
+ };
+
+
+@@ -103,11 +109,17 @@ G_DEFINE_TYPE (XfceMixerWindow, xfce_mixer_window, XFCE_TYPE_TITLED_DIALOG)
+ static void
+ xfce_mixer_window_class_init (XfceMixerWindowClass *klass)
+ {
+- GObjectClass *gobject_class;
++ GObjectClass *gobject_class;
++ GtkWidgetClass *gtk_widget_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->dispose = xfce_mixer_window_dispose;
+ gobject_class->finalize = xfce_mixer_window_finalize;
++
++ gtk_widget_class = GTK_WIDGET_CLASS (klass);
++ gtk_widget_class->size_allocate = xfce_mixer_window_size_allocate;
++ gtk_widget_class->window_state_event = xfce_mixer_window_state_event;
++ gtk_widget_class->destroy = xfce_mixer_window_destroy;
+ }
+
+
+@@ -115,8 +127,7 @@ xfce_mixer_window_class_init (XfceMixerWindowClass *klass)
+ static void
+ xfce_mixer_window_init (XfceMixerWindow *window)
+ {
+- GtkAccelGroup *accel_group;
+- GtkAction *action;
++ GApplication *app = g_application_get_default ();
+ GtkWidget *label;
+ GtkWidget *button;
+ GtkWidget *vbox;
+@@ -124,15 +135,18 @@ xfce_mixer_window_init (XfceMixerWindow *window)
+ GtkWidget *bbox;
+ gchar *card_name;
+ GstElement *card;
+- guint i;
+- gint width;
+- gint height;
++ const gchar *select_controls_accels[] = { "<Control>s", NULL };
++ const gchar *quit_accels[] = { "<Control>q", NULL };
+
+ window->controls_dialog = NULL;
+
+ window->preferences = xfce_mixer_preferences_get ();
+
+- g_object_get (window->preferences, "window-width", &width, "window-height", &height, "sound-card", &card_name, NULL);
++ window->is_maximized = FALSE;
++ window->is_fullscreen = FALSE;
++
++ g_object_get (window->preferences, "window-width", &window->current_width, "window-height", &window->current_height,
++ "sound-card", &card_name, NULL);
+ if (card_name != NULL)
+ card = xfce_mixer_get_card (card_name);
+ else
+@@ -148,36 +162,21 @@ xfce_mixer_window_init (XfceMixerWindow *window)
+ gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_NORMAL);
+ gtk_window_set_icon_name (GTK_WINDOW (window), "multimedia-volume-control");
+ gtk_window_set_title (GTK_WINDOW (window), _("Audio Mixer"));
+- gtk_window_set_default_size (GTK_WINDOW (window), width, height);
++ gtk_window_set_default_size (GTK_WINDOW (window), window->current_width, window->current_height);
+ gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
+- gtk_dialog_set_has_separator (GTK_DIALOG (window), FALSE);
+ xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (window), _("Configure sound card(s) and control the volume of selected tracks"));
+
+- g_signal_connect (window, "delete-event", G_CALLBACK (xfce_mixer_window_closed), window);
+-
+- /* Quit mixer when the main window is closed */
+- g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (gtk_main_quit), NULL);
+-
+- /* Create window action group */
+- window->action_group = gtk_action_group_new ("XfceMixerWindow");
+- gtk_action_group_set_translation_domain (window->action_group, GETTEXT_PACKAGE);
+- gtk_action_group_add_actions (window->action_group, action_entries, G_N_ELEMENTS (action_entries), GTK_WIDGET (window));
++ /* Install actions */
++ g_action_map_add_action_entries (G_ACTION_MAP (app), action_entries, G_N_ELEMENTS (action_entries), window);
+
+ /* Install action accelerators for the mixer window */
+- accel_group = gtk_accel_group_new ();
+- for (i = 0; i < G_N_ELEMENTS (action_entries); ++i)
+- {
+- action = gtk_action_group_get_action (window->action_group, action_entries[i].name);
+- gtk_action_set_accel_group (action, accel_group);
+- gtk_action_connect_accelerator (action);
+- gtk_action_set_sensitive (action, TRUE);
+- }
+- gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
++ gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.select-controls", select_controls_accels);
++ gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.quit", quit_accels);
+
+ vbox = gtk_dialog_get_content_area (GTK_DIALOG (window));
+ gtk_widget_show (vbox);
+
+- hbox = gtk_hbox_new (FALSE, 12);
++ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
+ gtk_widget_show (hbox);
+@@ -188,37 +187,40 @@ xfce_mixer_window_init (XfceMixerWindow *window)
+
+ window->soundcard_combo = xfce_mixer_card_combo_new (card);
+ g_signal_connect (G_OBJECT (window->soundcard_combo), "soundcard-changed", G_CALLBACK (xfce_mixer_window_soundcard_changed), window);
+- gtk_container_add (GTK_CONTAINER (hbox), window->soundcard_combo);
++ gtk_box_pack_start (GTK_BOX (hbox), window->soundcard_combo, TRUE, TRUE, 0);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), window->soundcard_combo);
+ gtk_widget_show (window->soundcard_combo);
+
+ window->mixer_frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (window->mixer_frame), GTK_SHADOW_NONE);
+ gtk_container_set_border_width (GTK_CONTAINER (window->mixer_frame), 6);
+- gtk_container_add (GTK_CONTAINER (vbox), window->mixer_frame);
++ gtk_box_pack_start (GTK_BOX (vbox), window->mixer_frame, TRUE, TRUE, 0);
+ gtk_widget_show (window->mixer_frame);
+
+ window->mixer_container = xfce_mixer_container_new (NULL);
+ gtk_container_add (GTK_CONTAINER (window->mixer_frame), window->mixer_container);
+ gtk_widget_show (window->mixer_container);
+
++G_GNUC_BEGIN_IGNORE_DEPRECATIONS
++ /* Single place still using deprecated API. GTK+ uses it internally as well, so why should we suffer?
++ Suffice it to say, new API is quite limited. */
+ bbox = gtk_dialog_get_action_area (GTK_DIALOG (window));
++G_GNUC_END_IGNORE_DEPRECATIONS
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_EDGE);
+ gtk_container_set_border_width (GTK_CONTAINER (bbox), 6);
+
+- window->select_controls_button = gtk_button_new ();
+- gtk_activatable_set_related_action (GTK_ACTIVATABLE (window->select_controls_button),
+- gtk_action_group_get_action (window->action_group, "select-controls"));
++ window->select_controls_button = gtk_button_new_with_mnemonic (_("_Select Controls..."));
+ gtk_button_set_image (GTK_BUTTON (window->select_controls_button),
+ gtk_image_new_from_icon_name ("preferences-desktop", GTK_ICON_SIZE_BUTTON));
++ gtk_actionable_set_action_name (GTK_ACTIONABLE (window->select_controls_button), "app.select-controls");
+ gtk_widget_set_sensitive (window->select_controls_button, FALSE);
+ gtk_box_pack_start (GTK_BOX (bbox), window->select_controls_button, FALSE, TRUE, 0);
+ gtk_widget_show (window->select_controls_button);
+
+- button = gtk_button_new ();
+- gtk_activatable_set_related_action (GTK_ACTIVATABLE (button),
+- gtk_action_group_get_action (window->action_group, "quit"));
+- gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_QUIT, GTK_ICON_SIZE_BUTTON));
++ button = gtk_button_new_with_mnemonic (_("_Quit"));
++ gtk_button_set_image (GTK_BUTTON (button),
++ gtk_image_new_from_icon_name ("exit", GTK_ICON_SIZE_BUTTON));
++ gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.quit");
+ gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, TRUE, 0);
+ gtk_widget_show (button);
+
+@@ -252,10 +254,55 @@ xfce_mixer_window_finalize (GObject *object)
+
+
+
++static void
++xfce_mixer_window_size_allocate (GtkWidget *widget,
++ GtkAllocation *allocation)
++{
++ XfceMixerWindow *window = XFCE_MIXER_WINDOW (widget);
++
++ (*GTK_WIDGET_CLASS (xfce_mixer_window_parent_class)->size_allocate) (widget, allocation);
++
++ if (!window->is_maximized && !window->is_fullscreen)
++ gtk_window_get_size (GTK_WINDOW (window), &window->current_width, &window->current_height);
++}
++
++
++
++static gboolean
++xfce_mixer_window_state_event (GtkWidget *widget,
++ GdkEventWindowState *event)
++{
++ XfceMixerWindow *window = XFCE_MIXER_WINDOW (widget);
++ gboolean result = GDK_EVENT_PROPAGATE;
++
++ if (GTK_WIDGET_CLASS (xfce_mixer_window_parent_class)->window_state_event != NULL)
++ result = (*GTK_WIDGET_CLASS (xfce_mixer_window_parent_class)->window_state_event) (widget, event);
++
++ window->is_maximized = (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0;
++ window->is_fullscreen = (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) != 0;
++
++ return result;
++}
++
++
++
++static void
++xfce_mixer_window_destroy (GtkWidget *widget)
++{
++ XfceMixerWindow *window = XFCE_MIXER_WINDOW (widget);
++
++ g_object_set (G_OBJECT (window->preferences), "window-width", window->current_width,
++ "window-height", window->current_height, NULL);
++
++ (*GTK_WIDGET_CLASS (xfce_mixer_window_parent_class)->destroy) (widget);
++}
++
++
++
+ GtkWidget*
+-xfce_mixer_window_new (void)
++xfce_mixer_window_new (GApplication *app)
+ {
+- return g_object_new (TYPE_XFCE_MIXER_WINDOW, NULL);
++ return g_object_new (TYPE_XFCE_MIXER_WINDOW, "application", app, NULL);
+ }
+
+
+@@ -334,9 +381,12 @@ xfce_mixer_window_soundcard_property_changed (XfceMixerWindow *window,
+
+
+ static void
+-xfce_mixer_window_action_select_controls (GtkAction *action,
+- XfceMixerWindow *window)
++xfce_mixer_window_action_select_controls (GSimpleAction *action,
++ GVariant *parameter,
++ gpointer user_data)
+ {
++ XfceMixerWindow *window = XFCE_MIXER_WINDOW (user_data);
++
+ g_return_if_fail (window->controls_dialog == NULL);
+
+ window->controls_dialog = xfce_mixer_controls_dialog_new (window);
+@@ -363,29 +413,15 @@ xfce_mixer_window_controls_property_changed (XfceMixerWindow *window,
+
+
+ static void
+-xfce_mixer_window_close (GtkAction *action,
+- XfceMixerWindow *window)
++xfce_mixer_window_close (GSimpleAction *action,
++ GVariant *parameter,
++ gpointer user_data)
+ {
+- /* This is a nasty hack to save the settings before the application quits */
+- xfce_mixer_window_closed (GTK_WIDGET (window), NULL, window);
+-}
+-
+-
+-
+-static gboolean
+-xfce_mixer_window_closed (GtkWidget *window,
+- GdkEvent *event,
+- XfceMixerWindow *mixer_window)
+-{
+- gint width;
+- gint height;
+-
+- gtk_window_get_size (GTK_WINDOW (mixer_window), &width, &height);
+- g_object_set (G_OBJECT (mixer_window->preferences), "window-width", width, "window-height", height, NULL);
++ XfceMixerWindow *window = XFCE_MIXER_WINDOW (user_data);
+
+- gtk_main_quit ();
++ gtk_widget_destroy (GTK_WIDGET (window));
+
+- return TRUE;
++ g_application_quit (g_application_get_default ());
+ }
+
+
+diff --git a/xfce4-mixer/xfce-mixer-window.h b/xfce4-mixer/xfce-mixer-window.h
+index b2aba01..b9ff14a 100644
+--- a/xfce4-mixer/xfce-mixer-window.h
++++ b/xfce4-mixer/xfce-mixer-window.h
+@@ -38,7 +38,7 @@ typedef struct _XfceMixerWindow XfceMixerWindow;
+
+ GType xfce_mixer_window_get_type (void) G_GNUC_CONST;
+
+-GtkWidget *xfce_mixer_window_new (void);
++GtkWidget *xfce_mixer_window_new (GApplication *app);
+ GstElement *xfce_mixer_window_get_active_card (XfceMixerWindow *window);
+
+ G_END_DECLS