Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • panel-plugins/xfce4-pulseaudio-plugin
  • bobby285271/xfce4-pulseaudio-plugin
  • sgn/xfce4-pulseaudio-plugin
  • bodqhrohro/xfce4-pulseaudio-plugin
  • correctmost/xfce4-pulseaudio-plugin
  • andrzejr/xfce4-pulseaudio-plugin
  • Zetta1_Reid0/xfce4-pulseaudio-plugin
7 results
Show changes
Showing
with 1802 additions and 1302 deletions
......@@ -10,6 +10,13 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment-max-volume">
<property name="lower">1</property>
<property name="upper">300</property>
<property name="value">150</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
......@@ -24,13 +31,35 @@
<columns>
<!-- column-name gicon -->
<column type="GIcon"/>
<!-- column-name label -->
<column type="gchararray"/>
<!-- column-name persistent -->
<column type="gboolean"/>
<!-- column-name ignored -->
<column type="gboolean"/>
<!-- column-name player -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="notifications-store">
<columns>
<!-- column-name label -->
<column type="gchararray"/>
<!-- column-name hidden -->
<column type="gboolean"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">None</col>
</row>
<row>
<col id="0" translatable="yes">All</col>
</row>
<row>
<col id="0" translatable="yes">Output only</col>
</row>
<row>
<col id="0" translatable="yes">Input only</col>
</row>
</data>
</object>
<object class="XfceTitledDialog" id="dialog">
<property name="can_focus">False</property>
......@@ -135,12 +164,12 @@
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton-show-notifications">
<property name="label" translatable="yes">Show _notifications when volume changes</property>
<object class="GtkCheckButton" id="checkbutton-play-sound">
<property name="label" translatable="yes">Play system _sound when volume changes</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Enables on-screen volume notifications.</property>
<property name="tooltip_text" translatable="yes">Enables audio feedback when using multimedia keys to change the volume.</property>
<property name="halign">start</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
......@@ -152,12 +181,11 @@
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton-play-sound">
<property name="label" translatable="yes">Play system _sound when volume changes</property>
<object class="GtkCheckButton" id="checkbutton-rec-indicator-persistent">
<property name="label" translatable="yes">Always display the recording _indicator</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Enables audio feedback when using multimedia keys to change the volume.</property>
<property name="halign">start</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
......@@ -168,18 +196,64 @@
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="vbox2-hbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Show volume _notifications:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">combobox-notifications</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="combobox-notifications">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Mute/unmute is notified in all modes except "None"</property>
<property name="model">notifications-store</property>
<child>
<object class="GtkCellRendererText" id="cb_text_render"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkBox" id="vbox2-hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Step size used when adjusting volume with mouse wheel.</property>
<property name="tooltip_text" translatable="yes">Step size used when adjusting volume with mouse wheel or hotkeys.</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Mouse wheel volume step:</property>
<property name="label" translatable="yes">_Volume step:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">spinbutton-volume-step</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -214,6 +288,52 @@
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">M_aximum volume:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">spinbutton-max-volume</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton-max-volume">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="halign">start</property>
<property name="max_length">3</property>
<property name="width_chars">3</property>
<property name="max_width_chars">4</property>
<property name="caps_lock_warning">False</property>
<property name="adjustment">adjustment-max-volume</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
</child>
</object>
......@@ -411,6 +531,21 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton-multimedia-keys-to-all">
<property name="label" translatable="yes">Send multimedia keys to all players</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton-wnck">
<property name="label" translatable="yes">Enable experimental window focus support</property>
......@@ -423,7 +558,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
</object>
......@@ -491,21 +626,32 @@
</child>
<child>
<object class="GtkTreeViewColumn" id="col_label">
<property name="title" translatable="yes">Title</property>
<property name="title" translatable="yes">Name</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="col_label_renderer"/>
<attributes>
<attribute name="text">2</attribute>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="col_persistent">
<property name="title" translatable="yes">Persistent</property>
<child>
<object class="GtkCellRendererToggle" id="col_persistent_renderer"/>
<attributes>
<attribute name="active">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="col_hidden">
<property name="title" translatable="yes">Hidden</property>
<object class="GtkTreeViewColumn" id="col_ignored">
<property name="title" translatable="yes">Ignored</property>
<child>
<object class="GtkCellRendererToggle" id="col_hidden_renderer"/>
<object class="GtkCellRendererToggle" id="col_ignored_renderer"/>
<attributes>
<attribute name="active">3</attribute>
</attributes>
......@@ -545,7 +691,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Please restart your panel for additional players to be displayed.</property>
<property name="label" translatable="yes">Please restart the players to make them visible again.</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
<attributes>
......
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/xfce/pulseaudio-plugin">
<file>pulseaudio-dialog.glade</file>
</gresource>
</gresources>
......@@ -54,6 +54,7 @@ struct _PulseaudioMenu
GtkWidget *output_scale;
GtkWidget *input_scale;
gulong connection_changed_id;
gulong volume_changed_id;
gulong volume_mic_changed_id;
};
......@@ -87,14 +88,6 @@ pulseaudio_menu_class_init (PulseaudioMenuClass *klass)
static void
pulseaudio_menu_init (PulseaudioMenu *menu)
{
menu->volume = NULL;
menu->config = NULL;
menu->mpris = NULL;
menu->button = NULL;
menu->output_scale = NULL;
menu->input_scale = NULL;
menu->volume_changed_id = 0;
menu->volume_mic_changed_id = 0;
}
......@@ -106,21 +99,15 @@ pulseaudio_menu_finalize (GObject *object)
menu = PULSEAUDIO_MENU (object);
if (menu->connection_changed_id != 0)
g_signal_handler_disconnect (G_OBJECT (menu->volume), menu->connection_changed_id);
if (menu->volume_changed_id != 0)
g_signal_handler_disconnect (G_OBJECT (menu->volume), menu->volume_changed_id);
if (menu->volume_mic_changed_id != 0)
g_signal_handler_disconnect (G_OBJECT (menu->volume), menu->volume_mic_changed_id);
menu->volume = NULL;
menu->config = NULL;
menu->mpris = NULL;
menu->button = NULL;
menu->output_scale = NULL;
menu->input_scale = NULL;
menu->volume_changed_id = 0;
menu->volume_mic_changed_id = 0;
G_OBJECT_CLASS (pulseaudio_menu_parent_class)->finalize (object);
}
......@@ -156,7 +143,7 @@ pulseaudio_menu_output_range_value_changed (PulseaudioMenu *menu,
g_return_if_fail (IS_PULSEAUDIO_MENU (menu));
new_volume = scale_menu_item_get_value (SCALE_MENU_ITEM (menu->output_scale)) / 100.0;
new_volume = xfpa_scale_menu_item_get_value (XFPA_SCALE_MENU_ITEM (menu->output_scale)) / 100.0;
pulseaudio_volume_set_volume (menu->volume, new_volume);
}
......@@ -164,11 +151,11 @@ pulseaudio_menu_output_range_value_changed (PulseaudioMenu *menu,
static void
pulseaudio_menu_mute_output_item_toggled (PulseaudioMenu *menu,
ScaleMenuItem *menu_item)
XfpaScaleMenuItem *menu_item)
{
g_return_if_fail (IS_PULSEAUDIO_MENU (menu));
pulseaudio_volume_set_muted (menu->volume, scale_menu_item_get_muted (menu_item));
pulseaudio_volume_set_muted (menu->volume, xfpa_scale_menu_item_get_muted (menu_item));
}
......@@ -227,7 +214,7 @@ pulseaudio_menu_input_range_value_changed (PulseaudioMenu *menu,
g_return_if_fail (IS_PULSEAUDIO_MENU (menu));
new_volume_mic = scale_menu_item_get_value (SCALE_MENU_ITEM (menu->input_scale)) / 100.0;
new_volume_mic = xfpa_scale_menu_item_get_value (XFPA_SCALE_MENU_ITEM (menu->input_scale)) / 100.0;
pulseaudio_volume_set_volume_mic (menu->volume, new_volume_mic);
}
......@@ -235,11 +222,11 @@ pulseaudio_menu_input_range_value_changed (PulseaudioMenu *menu,
static void
pulseaudio_menu_mute_input_item_toggled (PulseaudioMenu *menu,
ScaleMenuItem *menu_item)
XfpaScaleMenuItem *menu_item)
{
g_return_if_fail (IS_PULSEAUDIO_MENU (menu));
pulseaudio_volume_set_muted_mic (menu->volume, scale_menu_item_get_muted (menu_item));
pulseaudio_volume_set_muted_mic (menu->volume, xfpa_scale_menu_item_get_muted (menu_item));
}
......@@ -253,9 +240,9 @@ pulseaudio_menu_run_audio_mixer (PulseaudioMenu *menu,
g_return_if_fail (IS_PULSEAUDIO_MENU (menu));
if (!xfce_spawn_command_line_on_screen (gtk_widget_get_screen (GTK_WIDGET (menu)),
pulseaudio_config_get_mixer_command (menu->config),
FALSE, FALSE, &error))
if (!xfce_spawn_command_line (gtk_widget_get_screen (GTK_WIDGET (menu)),
pulseaudio_config_get_mixer_command (menu->config),
FALSE, FALSE, TRUE, &error))
{
message_dialog = gtk_message_dialog_new_with_markup (NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
......@@ -293,6 +280,29 @@ pulseaudio_menu_activate_playlist (PulseaudioMenu *menu,
static void
pulseaudio_menu_connection_changed (PulseaudioMenu *menu,
PulseaudioVolume *volume)
{
g_return_if_fail(IS_PULSEAUDIO_MENU(menu));
if (menu->volume_changed_id != 0)
{
g_signal_handler_disconnect (G_OBJECT (menu->volume), menu->volume_changed_id);
menu->volume_changed_id = 0;
}
if (menu->volume_mic_changed_id != 0)
{
g_signal_handler_disconnect (G_OBJECT (menu->volume), menu->volume_mic_changed_id);
menu->volume_mic_changed_id = 0;
}
gtk_widget_set_visible (GTK_WIDGET (menu), FALSE);
}
static void
pulseaudio_menu_volume_changed (PulseaudioMenu *menu,
gboolean should_notify,
......@@ -306,13 +316,13 @@ pulseaudio_menu_volume_changed (PulseaudioMenu *menu,
g_signal_handlers_block_by_func (G_OBJECT (menu->output_scale),
pulseaudio_menu_mute_output_item_toggled,
menu);
scale_menu_item_set_muted (SCALE_MENU_ITEM (menu->output_scale),
pulseaudio_volume_get_muted (volume));
xfpa_scale_menu_item_set_muted (XFPA_SCALE_MENU_ITEM (menu->output_scale),
pulseaudio_volume_get_muted (volume));
g_signal_handlers_unblock_by_func (G_OBJECT (menu->output_scale),
pulseaudio_menu_mute_output_item_toggled,
menu);
scale_menu_item_set_value (SCALE_MENU_ITEM (menu->output_scale),
pulseaudio_volume_get_volume (menu->volume) * 100.0);
xfpa_scale_menu_item_set_value (XFPA_SCALE_MENU_ITEM (menu->output_scale),
pulseaudio_volume_get_volume (menu->volume) * 100.0);
}
if (menu->input_scale != NULL)
......@@ -320,13 +330,13 @@ pulseaudio_menu_volume_changed (PulseaudioMenu *menu,
g_signal_handlers_block_by_func (G_OBJECT (menu->input_scale),
pulseaudio_menu_mute_input_item_toggled,
menu);
scale_menu_item_set_muted (SCALE_MENU_ITEM (menu->input_scale),
pulseaudio_volume_get_muted_mic (volume));
xfpa_scale_menu_item_set_muted (XFPA_SCALE_MENU_ITEM (menu->input_scale),
pulseaudio_volume_get_muted_mic (volume));
g_signal_handlers_unblock_by_func (G_OBJECT (menu->input_scale),
pulseaudio_menu_mute_input_item_toggled,
menu);
scale_menu_item_set_value (SCALE_MENU_ITEM (menu->input_scale),
pulseaudio_volume_get_volume_mic (menu->volume) * 100.0);
xfpa_scale_menu_item_set_value (XFPA_SCALE_MENU_ITEM (menu->input_scale),
pulseaudio_volume_get_volume_mic (menu->volume) * 100.0);
}
}
......@@ -357,7 +367,6 @@ mpris_update_cb (PulseaudioMpris *mpris,
gchar *title;
gchar *artist;
gboolean is_running;
gboolean is_playing;
gboolean is_stopped;
gboolean can_play;
......@@ -365,7 +374,6 @@ mpris_update_cb (PulseaudioMpris *mpris,
gboolean can_go_previous;
gboolean can_go_next;
gboolean can_raise;
GList *playlists;
g_return_if_fail (IS_PULSEAUDIO_MPRIS (mpris));
g_return_if_fail (IS_MPRIS_MENU_ITEM (menu_item));
......@@ -379,7 +387,6 @@ mpris_update_cb (PulseaudioMpris *mpris,
player,
&title,
&artist,
&is_running,
&is_playing,
&is_stopped,
&can_play,
......@@ -387,9 +394,10 @@ mpris_update_cb (PulseaudioMpris *mpris,
&can_go_previous,
&can_go_next,
&can_raise,
&playlists))
NULL))
{
mpris_menu_item_set_is_running (menu_item, is_running);
mpris_menu_item_set_is_running (menu_item, TRUE);
mpris_menu_item_set_title (menu_item, title);
mpris_menu_item_set_artist (menu_item, artist);
......@@ -401,14 +409,14 @@ mpris_update_cb (PulseaudioMpris *mpris,
mpris_menu_item_set_is_playing (menu_item, is_playing);
mpris_menu_item_set_is_stopped (menu_item, is_stopped);
}
if (title != NULL)
g_free (title);
if (artist != NULL)
g_free (artist);
if (playlists != NULL)
g_list_free (playlists);
g_free (title);
g_free (artist);
}
else
{
mpris_menu_item_set_is_running (menu_item, FALSE);
}
}
}
......@@ -444,8 +452,11 @@ pulseaudio_menu_new (PulseaudioVolume *volume,
GList *sources = NULL;
GList *list = NULL;
guint i = 0;
gchar *name;
gboolean available;
#ifdef HAVE_MPRIS2
guint num_players;
gchar **players;
gchar *title = NULL;
gchar *artist = NULL;
......@@ -477,6 +488,9 @@ pulseaudio_menu_new (PulseaudioVolume *volume,
menu->config = config;
menu->mpris = mpris;
menu->button = widget;
menu->connection_changed_id =
g_signal_connect_swapped (G_OBJECT (menu->volume), "connection-changed",
G_CALLBACK (pulseaudio_menu_connection_changed), menu);
menu->volume_changed_id =
g_signal_connect_swapped (G_OBJECT (menu->volume), "volume-changed",
G_CALLBACK (pulseaudio_menu_volume_changed), menu);
......@@ -491,8 +505,8 @@ pulseaudio_menu_new (PulseaudioVolume *volume,
if (g_list_length (sources) > 0)
{
/* output volume slider */
menu->output_scale = scale_menu_item_new_with_range (0.0, volume_max, 1.0);
scale_menu_item_set_base_icon_name (SCALE_MENU_ITEM (menu->output_scale), "audio-volume");
menu->output_scale = xfpa_scale_menu_item_new_with_range (0.0, volume_max, 1.0, -1.0);
xfpa_scale_menu_item_set_base_icon_name (XFPA_SCALE_MENU_ITEM (menu->output_scale), "audio-volume");
g_signal_connect_swapped (menu->output_scale, "value-changed", G_CALLBACK (pulseaudio_menu_output_range_value_changed), menu);
g_signal_connect_swapped (menu->output_scale, "toggled", G_CALLBACK (pulseaudio_menu_mute_output_item_toggled), menu);
......@@ -507,7 +521,8 @@ pulseaudio_menu_new (PulseaudioVolume *volume,
device_mi = device_menu_item_new_with_label(_("Output"));
for (list = sources; list != NULL; list = g_list_next(list))
{
device_menu_item_add_device(DEVICE_MENU_ITEM(device_mi), (gchar *)list->data, pulseaudio_volume_get_output_by_name(menu->volume, list->data));
name = pulseaudio_volume_get_output_by_name(menu->volume, list->data, &available);
device_menu_item_add_device(DEVICE_MENU_ITEM(device_mi), (gchar *)list->data, name, available);
}
device_menu_item_set_device_by_name(DEVICE_MENU_ITEM(device_mi), pulseaudio_volume_get_default_output(menu->volume));
......@@ -530,8 +545,8 @@ pulseaudio_menu_new (PulseaudioVolume *volume,
if (g_list_length (sources) > 0)
{
/* input volume slider */
menu->input_scale = scale_menu_item_new_with_range (0.0, volume_max, 1.0);
scale_menu_item_set_base_icon_name (SCALE_MENU_ITEM (menu->input_scale), "microphone-sensitivity");
menu->input_scale = xfpa_scale_menu_item_new_with_range (0.0, volume_max, 1.0, pulseaudio_volume_get_base_volume_mic (menu->volume) * 100.0);
xfpa_scale_menu_item_set_base_icon_name (XFPA_SCALE_MENU_ITEM (menu->input_scale), "microphone-sensitivity");
g_signal_connect_swapped (menu->input_scale, "value-changed", G_CALLBACK (pulseaudio_menu_input_range_value_changed), menu);
g_signal_connect_swapped (menu->input_scale, "toggled", G_CALLBACK (pulseaudio_menu_mute_input_item_toggled), menu);
......@@ -546,7 +561,8 @@ pulseaudio_menu_new (PulseaudioVolume *volume,
device_mi = device_menu_item_new_with_label(_("Input"));
for (list = sources; list != NULL; list = g_list_next(list))
{
device_menu_item_add_device(DEVICE_MENU_ITEM(device_mi), (gchar *)list->data, pulseaudio_volume_get_input_by_name(menu->volume, list->data));
name = pulseaudio_volume_get_input_by_name(menu->volume, list->data, &available);
device_menu_item_add_device(DEVICE_MENU_ITEM(device_mi), (gchar *)list->data, name, available);
}
device_menu_item_set_device_by_name(DEVICE_MENU_ITEM(device_mi), pulseaudio_volume_get_default_input(menu->volume));
......@@ -568,98 +584,109 @@ pulseaudio_menu_new (PulseaudioVolume *volume,
#ifdef HAVE_MPRIS2
if (pulseaudio_config_get_enable_mpris (menu->config))
{
players = pulseaudio_config_get_mpris_players (menu->config);
players = pulseaudio_config_get_known_players (menu->config);
if (players != NULL)
{
for (i = 0; i < g_strv_length (players); i++)
num_players = g_strv_length (players);
for (i = 0; i < num_players; i++)
{
if (pulseaudio_config_player_blacklist_lookup (menu->config, players[i]))
if (pulseaudio_config_player_ignored_lookup (menu->config, players[i]))
continue;
is_running = pulseaudio_mpris_get_player_snapshot (menu->mpris,
players[i],
&title,
&artist,
&is_playing,
&is_stopped,
&can_play,
&can_pause,
&can_go_previous,
&can_go_next,
&can_raise,
&playlists);
if (!is_running && !pulseaudio_config_player_persistent_lookup (menu->config, players[i]))
continue;
mi = mpris_menu_item_new_from_player_name (players[i]);
if (mi != NULL)
if (mi == NULL)
{
if (pulseaudio_mpris_get_player_snapshot (menu->mpris,
players[i],
&title,
&artist,
&is_running,
&is_playing,
&is_stopped,
&can_play,
&can_pause,
&can_go_previous,
&can_go_next,
&can_raise,
&playlists))
if (is_running)
{
mpris_menu_item_set_is_running (MPRIS_MENU_ITEM (mi), is_running);
mpris_menu_item_set_title (MPRIS_MENU_ITEM (mi), title);
mpris_menu_item_set_artist (MPRIS_MENU_ITEM (mi), artist);
if (playlists)
g_list_free (playlists);
g_free (title);
g_free (artist);
}
continue;
}
mpris_menu_item_set_can_raise (MPRIS_MENU_ITEM (mi), can_raise);
mpris_menu_item_set_can_raise_wnck (MPRIS_MENU_ITEM (mi), pulseaudio_config_get_can_raise_wnck (menu->config));
if (is_running)
{
mpris_menu_item_set_is_running (MPRIS_MENU_ITEM (mi), TRUE);
mpris_menu_item_set_can_play (MPRIS_MENU_ITEM (mi), can_play);
mpris_menu_item_set_can_pause (MPRIS_MENU_ITEM (mi), can_pause);
mpris_menu_item_set_title (MPRIS_MENU_ITEM (mi), title);
mpris_menu_item_set_artist (MPRIS_MENU_ITEM (mi), artist);
mpris_menu_item_set_can_go_previous (MPRIS_MENU_ITEM (mi), can_go_previous);
mpris_menu_item_set_can_go_next (MPRIS_MENU_ITEM (mi), can_go_next);
mpris_menu_item_set_can_raise (MPRIS_MENU_ITEM (mi), can_raise);
mpris_menu_item_set_can_raise_wnck (MPRIS_MENU_ITEM (mi), pulseaudio_config_get_can_raise_wnck (menu->config));
mpris_menu_item_set_is_playing (MPRIS_MENU_ITEM (mi), is_playing);
mpris_menu_item_set_is_stopped (MPRIS_MENU_ITEM (mi), is_stopped);
mpris_menu_item_set_can_play (MPRIS_MENU_ITEM (mi), can_play);
mpris_menu_item_set_can_pause (MPRIS_MENU_ITEM (mi), can_pause);
if (title != NULL)
g_free (title);
if (artist != NULL)
g_free (artist);
}
else
{
mpris_menu_item_set_is_running (MPRIS_MENU_ITEM (mi), FALSE);
mpris_menu_item_set_is_stopped (MPRIS_MENU_ITEM (mi), TRUE);
}
mpris_menu_item_set_can_go_previous (MPRIS_MENU_ITEM (mi), can_go_previous);
mpris_menu_item_set_can_go_next (MPRIS_MENU_ITEM (mi), can_go_next);
g_signal_connect (mi, "media-notify", G_CALLBACK (media_notify_cb), menu);
g_signal_connect (menu->mpris, "update", G_CALLBACK (mpris_update_cb), mi);
g_signal_connect (mi, "destroy", G_CALLBACK(item_destroy_cb), menu);
mpris_menu_item_set_is_playing (MPRIS_MENU_ITEM (mi), is_playing);
mpris_menu_item_set_is_stopped (MPRIS_MENU_ITEM (mi), is_stopped);
gtk_widget_show(mi);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
g_free (title);
g_free (artist);
}
else
{
mpris_menu_item_set_is_running (MPRIS_MENU_ITEM (mi), FALSE);
}
g_signal_connect (mi, "media-notify", G_CALLBACK (media_notify_cb), menu);
g_signal_connect (menu->mpris, "update", G_CALLBACK (mpris_update_cb), mi);
g_signal_connect (mi, "destroy", G_CALLBACK(item_destroy_cb), menu);
gtk_widget_show(mi);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
if (is_running && playlists != NULL)
{
if (g_list_length(playlists) > 0)
{
mi = gtk_menu_item_new_with_label(_("Choose Playlist"));
gtk_widget_show(mi);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
submenu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(mi), submenu);
if (playlists != NULL)
for (list = playlists; list != NULL; list = g_list_next(list))
{
if (g_list_length(playlists) > 0)
{
mi = gtk_menu_item_new_with_label(_("Choose Playlist"));
gtk_widget_show(mi);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
submenu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(mi), submenu);
for (list = playlists; list != NULL; list = g_list_next(list))
{
mi = gtk_menu_item_new_with_label((gchar *)list->data);
gtk_widget_show(mi);
gtk_menu_shell_append(GTK_MENU_SHELL(submenu), mi);
g_object_set_data (G_OBJECT(mi), "player", g_strdup (players[i]));
g_object_set_data (G_OBJECT(mi), "playlist", g_strdup ((gchar *)list->data));
g_signal_connect_swapped(G_OBJECT(mi), "activate", G_CALLBACK (pulseaudio_menu_activate_playlist), menu);
}
}
g_list_free(playlists);
playlists = NULL;
mi = gtk_menu_item_new_with_label((gchar *)list->data);
gtk_widget_show(mi);
gtk_menu_shell_append(GTK_MENU_SHELL(submenu), mi);
g_object_set_data (G_OBJECT(mi), "player", g_strdup (players[i]));
g_object_set_data (G_OBJECT(mi), "playlist", g_strdup ((gchar *)list->data));
g_signal_connect_swapped(G_OBJECT(mi), "activate", G_CALLBACK (pulseaudio_menu_activate_playlist), menu);
}
}
/* separator */
mi = gtk_separator_menu_item_new ();
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
g_list_free(playlists);
}
/* separator */
mi = gtk_separator_menu_item_new ();
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
}
g_strfreev (players);
......
......@@ -28,10 +28,6 @@
#ifdef HAVE_LIBXFCE4WINDOWING
#include <libxfce4windowing/libxfce4windowing.h>
#elif defined (HAVE_WNCK)
#define WNCK_I_KNOW_THIS_IS_UNSTABLE = 1
#include <libwnck/libwnck.h>
#include <gdk/gdkx.h>
#endif
#include "pulseaudio-mpris-player.h"
......@@ -50,6 +46,7 @@ struct _PulseaudioMprisPlayer
gchar *player;
gchar *player_label;
gchar *player_dbus_name;
gchar *icon_name;
gboolean connected;
......@@ -63,7 +60,6 @@ struct _PulseaudioMprisPlayer
gboolean can_pause;
gboolean can_play;
gboolean can_raise;
gboolean can_launch;
PlaybackStatus playback_status;
......@@ -73,9 +69,9 @@ struct _PulseaudioMprisPlayer
#ifdef HAVE_LIBXFCE4WINDOWING
XfwScreen *screen;
#elif defined (HAVE_WNCK)
gulong xid;
#endif
gint64 timestamp;
};
struct _PulseaudioMprisPlayerClass
......@@ -289,70 +285,19 @@ pulseaudio_mpris_player_raise_wnck (PulseaudioMprisPlayer *player)
{
if (g_strcmp0 (player->player_label, xfw_window_get_name (lp->data)) == 0)
{
xfw_window_activate (lp->data, g_get_monotonic_time () / 1000, NULL);
xfw_window_activate (lp->data, NULL, g_get_monotonic_time () / 1000, NULL);
break;
}
}
}
#elif defined (HAVE_WNCK)
static void
pulseaudio_mpris_player_get_xid (PulseaudioMprisPlayer *player)
{
WnckScreen *screen = NULL;
GList *window = NULL;
if (player->xid > 0L || ! GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
return;
screen = wnck_screen_get_default ();
if (screen != NULL)
{
wnck_screen_force_update (screen);
if (player->xid == 0L)
{
for (window = wnck_screen_get_windows (screen); window != NULL; window = window->next)
{
if (0 == g_strcmp0 (player->player_label, wnck_window_get_name (WNCK_WINDOW (window->data))))
{
player->xid = wnck_window_get_xid (WNCK_WINDOW (window->data));
if (player->xid > 0L)
return;
}
}
}
}
}
/**
* Alternative "Raise" method.
* Some media players (e.g. Spotify) do not support the "Raise" method.
* This workaround utilizes libwnck to find the correct window and raise it.
*/
static void
pulseaudio_mpris_player_raise_wnck (PulseaudioMprisPlayer *player)
{
WnckWindow *window = NULL;
pulseaudio_mpris_player_get_xid (player);
if (player->xid == 0L)
return;
window = wnck_window_get (player->xid);
if (window != NULL)
wnck_window_activate (window, g_get_monotonic_time () / 1000);
}
#endif
void
pulseaudio_mpris_player_call_player_method (PulseaudioMprisPlayer *player,
const gchar *method)
const gchar *method,
gboolean update_timestamp)
{
GDBusMessage *message;
GError *error = NULL;
......@@ -360,7 +305,7 @@ pulseaudio_mpris_player_call_player_method (PulseaudioMprisPlayer *player,
if (g_strcmp0 (method, "Raise") == 0)
iface = "org.mpris.MediaPlayer2";
#if defined (HAVE_WNCK) || defined (HAVE_LIBXFCE4WINDOWING)
#ifdef HAVE_LIBXFCE4WINDOWING
else if (g_strcmp0 (method, "RaiseWnck") == 0)
return pulseaudio_mpris_player_raise_wnck (player);
#endif
......@@ -394,6 +339,9 @@ pulseaudio_mpris_player_call_player_method (PulseaudioMprisPlayer *player,
}
g_object_unref (message);
if (update_timestamp)
player->timestamp = g_get_monotonic_time ();
}
......@@ -589,8 +537,11 @@ pulseaudio_mpris_player_parse_player_properties (PulseaudioMprisPlayer *player,
if (playback_status != NULL)
{
PlaybackStatus old_status = player->playback_status;
pulseaudio_mpris_player_parse_playback_status (player, playback_status);
g_signal_emit (player, signals[PLAYBACK_STATUS], 0, player->playback_status);
if (old_status != PLAYING && player->playback_status == PLAYING)
player->timestamp = g_get_monotonic_time ();
}
}
......@@ -603,7 +554,8 @@ pulseaudio_mpris_player_parse_media_player_properties (PulseaudioMprisPlayer *pl
GVariantIter iter;
GVariant *value;
const gchar *key;
const gchar *filename = NULL;
const gchar *name_for_desktop = NULL;
const gchar *identify = NULL;
g_variant_iter_init (&iter, properties);
......@@ -615,10 +567,23 @@ pulseaudio_mpris_player_parse_media_player_properties (PulseaudioMprisPlayer *pl
}
else if (0 == g_ascii_strcasecmp (key, "DesktopEntry"))
{
filename = g_variant_get_string(value, NULL);
pulseaudio_mpris_player_set_details_from_desktop (player, filename);
name_for_desktop = g_variant_get_string(value, NULL);
}
else if (0 == g_ascii_strcasecmp (key, "Identity"))
{
identify = g_variant_get_string(value, NULL);
}
}
if (name_for_desktop == NULL && identify != NULL && *identify != '\0')
player->player_label = g_strdup (identify);
if (name_for_desktop == NULL)
name_for_desktop = player->player_label;
if (name_for_desktop == NULL)
name_for_desktop = player->player;
player->player_dbus_name = g_strdup (name_for_desktop);
pulseaudio_mpris_player_set_details_from_desktop (player, player->player_dbus_name);
}
......@@ -690,27 +655,28 @@ pulseaudio_mpris_player_on_dbus_connected (GDBusConnection *connection,
player->connected = TRUE;
/* Notify that connect to a player.*/
g_signal_emit (player, signals[CONNECTION], 0, player->connected);
/* And informs the current status of the player */
reply = pulseaudio_mpris_player_get_all_player_properties (player);
/* Media player properties */
reply = pulseaudio_mpris_player_get_all_media_player_properties (player);
if (reply)
{
pulseaudio_mpris_player_parse_player_properties (player, reply);
pulseaudio_mpris_player_parse_media_player_properties (player, reply);
g_variant_unref (reply);
}
if (player->player_label == NULL)
pulseaudio_mpris_player_set_details_from_desktop (player, player->player);
/* Media player properties */
reply = pulseaudio_mpris_player_get_all_media_player_properties (player);
/* Notify that connect to a player */
g_signal_emit (player, signals[CONNECTION], 0, player->connected);
/* Inform the current status of the player */
reply = pulseaudio_mpris_player_get_all_player_properties (player);
if (reply)
{
pulseaudio_mpris_player_parse_media_player_properties (player, reply);
pulseaudio_mpris_player_parse_player_properties (player, reply);
g_variant_unref (reply);
}
/* Playlists */
reply = pulseaudio_mpris_player_playlists_get_playlists (player);
if (reply)
......@@ -718,10 +684,6 @@ pulseaudio_mpris_player_on_dbus_connected (GDBusConnection *connection,
pulseaudio_mpris_player_parse_playlists (player, reply);
g_variant_unref (reply);
}
#ifdef HAVE_WNCK
pulseaudio_mpris_player_get_xid (player);
#endif
}
......@@ -733,33 +695,19 @@ pulseaudio_mpris_player_on_dbus_lost (GDBusConnection *connection,
{
PulseaudioMprisPlayer *player = user_data;
/* Interface MediaPlayer2.Player */
player->playback_status = STOPPED;
player->can_go_next = FALSE;
player->can_go_previous = FALSE;
player->can_play = FALSE;
player->can_pause = FALSE;
player->can_raise = FALSE;
player->connected = FALSE;
if (player->title != NULL)
g_free (player->title);
if (player->artist != NULL)
g_free (player->artist);
if (!player->connected)
return;
player->title = NULL;
player->artist = NULL;
#ifdef HAVE_WNCK
player->xid = 0L;
#endif
player->connected = FALSE;
/* This will delete the object */
g_signal_emit (player, signals[CONNECTION], 0, player->connected);
}
static gchar *
find_desktop_entry (const gchar *player_name)
gchar *
pulseaudio_mpris_player_find_desktop_entry (const gchar *player_name)
{
GKeyFile *key_file;
gchar *file = NULL;
......@@ -811,17 +759,20 @@ pulseaudio_mpris_player_set_details_from_desktop (PulseaudioMprisPlayer *player,
gchar *full_path = NULL;
gchar *filename = NULL;
filename = find_desktop_entry (player_name);
if (G_UNLIKELY (player->player_dbus_name == NULL))
player->player_dbus_name = g_strdup (player_name);
filename = pulseaudio_mpris_player_find_desktop_entry (player_name);
if (player->player_label != NULL)
g_free (player->player_label);
if (player->icon_name != NULL)
g_free (player->icon_name);
g_free (player->icon_name);
g_free (player->full_path);
if (filename == NULL)
{
player->player_label = g_strdup (player->player);
if (player->player_label == NULL)
player->player_label = g_strdup (player->player);
player->icon_name = g_strdup ("applications-multimedia");
player->full_path = NULL;
return;
}
......@@ -831,25 +782,18 @@ pulseaudio_mpris_player_set_details_from_desktop (PulseaudioMprisPlayer *player,
key_file = g_key_file_new();
if (g_key_file_load_from_data_dirs (key_file, file, &full_path, G_KEY_FILE_NONE, NULL))
{
gchar *name = g_key_file_get_locale_string (key_file, "Desktop Entry", "Name", NULL, NULL);
gchar *icon_name = g_key_file_get_string (key_file, "Desktop Entry", "Icon", NULL);
player->player_label = g_strdup (name);
player->icon_name = g_strdup (icon_name);
g_free (name);
g_free (icon_name);
if (player->player_label == NULL)
player->player_label = g_key_file_get_locale_string (key_file, "Desktop Entry", "Name", NULL, NULL);
player->icon_name = g_key_file_get_string (key_file, "Desktop Entry", "Icon", NULL);
}
else
{
player->player_label = g_strdup (player->player);
if (player->player_label == NULL)
player->player_label = g_strdup (player->player);
player->icon_name = g_strdup ("applications-multimedia");
}
if (full_path != NULL) {
player->full_path = g_strdup (full_path);
g_free (full_path);
}
player->full_path = full_path;
g_key_file_free (key_file);
g_free (file);
......@@ -857,50 +801,6 @@ pulseaudio_mpris_player_set_details_from_desktop (PulseaudioMprisPlayer *player,
static void
pulseaudio_mpris_player_set_player (PulseaudioMprisPlayer *player,
const gchar *player_name)
{
/* Disconnect dbus */
if (player->watch_id)
{
g_bus_unwatch_name (player->watch_id);
player->watch_id = 0;
}
if (player->dbus_props_proxy != NULL)
{
g_object_unref (player->dbus_props_proxy);
player->dbus_props_proxy = NULL;
}
if (player->dbus_player_proxy != NULL)
{
g_object_unref (player->dbus_player_proxy);
player->dbus_player_proxy = NULL;
}
if (player->dbus_playlists_proxy != NULL)
{
g_object_unref (player->dbus_playlists_proxy);
player->dbus_playlists_proxy = NULL;
}
/* Clean player */
if (player->player != NULL)
{
g_free (player->player);
player->player = NULL;
}
/* Set new player and connect again */
player->player = g_strdup(player_name);
pulseaudio_mpris_player_set_details_from_desktop (player, player_name);
pulseaudio_mpris_player_dbus_connect (player);
player->can_launch = player->full_path != NULL;
}
static void
pulseaudio_mpris_player_dbus_connect (PulseaudioMprisPlayer *player)
{
......@@ -991,6 +891,14 @@ pulseaudio_mpris_player_dbus_connect (PulseaudioMprisPlayer *player)
gint64
pulseaudio_mpris_player_get_timestamp (PulseaudioMprisPlayer *player)
{
return player->timestamp;
}
const gchar *
pulseaudio_mpris_player_get_player (PulseaudioMprisPlayer *player)
{
......@@ -1000,13 +908,21 @@ pulseaudio_mpris_player_get_player (PulseaudioMprisPlayer *player)
const gchar *
pulseaudio_mpris_player_get_player_title (PulseaudioMprisPlayer *player)
pulseaudio_mpris_player_get_player_label (PulseaudioMprisPlayer *player)
{
return player->player_label;
}
const gchar *
pulseaudio_mpris_player_get_dbus_name (PulseaudioMprisPlayer *player)
{
return player->player_dbus_name;
}
const gchar *
pulseaudio_mpris_player_get_icon_name (PulseaudioMprisPlayer *player)
{
......@@ -1103,47 +1019,11 @@ pulseaudio_mpris_player_can_raise (PulseaudioMprisPlayer *player)
gboolean
pulseaudio_mpris_player_can_launch (PulseaudioMprisPlayer *player)
{
return player->can_launch;
}
gboolean
pulseaudio_mpris_player_is_equal (PulseaudioMprisPlayer *a,
PulseaudioMprisPlayer *b)
{
return g_strcmp0 (pulseaudio_mpris_player_get_player_title (a), pulseaudio_mpris_player_get_player_title (b)) == 0;
}
static void
pulseaudio_mpris_player_init (PulseaudioMprisPlayer *player)
{
player->dbus_connection = NULL;
player->dbus_name = NULL;
player->dbus_props_proxy = NULL;
player->dbus_player_proxy = NULL;
player->dbus_playlists_proxy = NULL;
player->connected = FALSE;
player->title = NULL;
player->artist = NULL;
player->full_path = NULL;
player->can_go_next = FALSE;
player->can_go_previous = FALSE;
player->can_pause = FALSE;
player->can_play = FALSE;
player->can_raise = FALSE;
player->playback_status = STOPPED;
player->watch_id = 0;
#ifdef HAVE_LIBXFCE4WINDOWING
player->screen = xfw_screen_get_default ();
#endif
......@@ -1158,26 +1038,24 @@ pulseaudio_mpris_player_finalize (GObject *object)
player = PULSEAUDIO_MPRIS_PLAYER (object);
player->dbus_connection = NULL;
player->dbus_name = NULL;
player->dbus_props_proxy = NULL;
player->dbus_player_proxy = NULL;
player->dbus_playlists_proxy = NULL;
player->connected = FALSE;
player->title = NULL;
player->artist = NULL;
player->full_path = NULL;
player->can_go_next = FALSE;
player->can_go_previous = FALSE;
player->can_pause = FALSE;
player->can_play = FALSE;
player->can_raise = FALSE;
/* Disconnect dbus */
if (player->watch_id != 0)
g_bus_unwatch_name (player->watch_id);
if (player->dbus_props_proxy != NULL)
g_object_unref (player->dbus_props_proxy);
if (player->dbus_player_proxy != NULL)
g_object_unref (player->dbus_player_proxy);
if (player->dbus_playlists_proxy != NULL)
g_object_unref (player->dbus_playlists_proxy);
player->playback_status = STOPPED;
g_free (player->player);
g_free (player->player_label);
g_free (player->player_dbus_name);
g_free (player->icon_name);
player->watch_id = 0;
g_free (player->title);
g_free (player->artist);
g_free (player->full_path);
if (player->playlists != NULL)
g_hash_table_destroy (player->playlists);
......@@ -1203,17 +1081,16 @@ pulseaudio_mpris_player_new (gchar *name)
{
g_message ("Failed to get session bus: %s", gerror->message);
g_error_free (gerror);
gerror = NULL;
return NULL;
}
player = g_object_new (TYPE_PULSEAUDIO_MPRIS_PLAYER, NULL);
player->dbus_connection = gconnection;
player->player = g_strdup (name);
player->playlists = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
pulseaudio_mpris_player_dbus_connect (player);
pulseaudio_mpris_player_set_player (player, name);
player->playlists = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)g_free);
return player;
}
......@@ -52,8 +52,12 @@ typedef struct _PulseaudioMprisPlayerClass PulseaudioMpr
PulseaudioMprisPlayer *pulseaudio_mpris_player_new (gchar *name);
gchar *pulseaudio_mpris_player_find_desktop_entry (const gchar *player_name);
gint64 pulseaudio_mpris_player_get_timestamp (PulseaudioMprisPlayer *player);
const gchar *pulseaudio_mpris_player_get_player (PulseaudioMprisPlayer *player);
const gchar *pulseaudio_mpris_player_get_player_title (PulseaudioMprisPlayer *player);
const gchar *pulseaudio_mpris_player_get_player_label (PulseaudioMprisPlayer *player);
const gchar *pulseaudio_mpris_player_get_dbus_name (PulseaudioMprisPlayer *player);
const gchar *pulseaudio_mpris_player_get_icon_name (PulseaudioMprisPlayer *player);
const gchar *pulseaudio_mpris_player_get_title (PulseaudioMprisPlayer *player);
const gchar *pulseaudio_mpris_player_get_artist (PulseaudioMprisPlayer *player);
......@@ -68,13 +72,10 @@ gboolean pulseaudio_mpris_player_can_pause (PulseaudioMp
gboolean pulseaudio_mpris_player_can_go_previous (PulseaudioMprisPlayer *player);
gboolean pulseaudio_mpris_player_can_go_next (PulseaudioMprisPlayer *player);
gboolean pulseaudio_mpris_player_can_raise (PulseaudioMprisPlayer *player);
gboolean pulseaudio_mpris_player_can_launch (PulseaudioMprisPlayer *player);
gboolean pulseaudio_mpris_player_is_equal (PulseaudioMprisPlayer *a,
PulseaudioMprisPlayer *b);
void pulseaudio_mpris_player_call_player_method (PulseaudioMprisPlayer *player,
const gchar *method);
const gchar *method,
gboolean update_timestamp);
GList *pulseaudio_mpris_player_get_playlists (PulseaudioMprisPlayer *player);
void pulseaudio_mpris_player_activate_playlist (PulseaudioMprisPlayer *player,
......
......@@ -38,8 +38,9 @@ struct _PulseaudioMpris
GDBusConnection *dbus_connection;
GHashTable *players;
GHashTable *players_by_dbus_name;
guint player_timer_id;
guint dbus_signal_id;
};
struct _PulseaudioMprisClass
......@@ -71,50 +72,6 @@ static PulseaudioMpris *mpris_instance;
static gchar *
find_desktop_entry (const gchar *player_name)
{
GKeyFile *key_file;
gchar *file = NULL;
gchar *filename = NULL;
file = g_strconcat ("applications/", player_name, ".desktop", NULL);
key_file = g_key_file_new();
if (g_key_file_load_from_data_dirs (key_file, file, NULL, G_KEY_FILE_NONE, NULL))
{
filename = g_strconcat (player_name, ".desktop", NULL);
}
else
{
/* Support reverse domain name (RDN) formatted launchers. */
gchar ***results = g_desktop_app_info_search (player_name);
gint i, j;
for (i = 0; results[i]; i++)
{
for (j = 0; results[i][j]; j++)
{
if (filename == NULL)
{
filename = g_strdup (results[i][j]);
}
}
g_strfreev (results[i]);
}
g_free (results);
}
g_key_file_free (key_file);
if (file)
g_free (file);
return filename;
}
static void
pulseaudio_mpris_class_init (PulseaudioMprisClass *klass)
{
......@@ -149,7 +106,7 @@ player_is_usable (PulseaudioMpris *mpris,
g_variant_new ("(s)", "org.mpris.MediaPlayer2"),
G_VARIANT_TYPE ("(a{sv})"),
G_DBUS_CALL_FLAGS_NONE,
-1,
5000,
NULL,
NULL);
......@@ -169,7 +126,7 @@ player_is_usable (PulseaudioMpris *mpris,
}
gchar **
static gchar **
pulseaudio_mpris_get_available_players (PulseaudioMpris *mpris)
{
GError *error = NULL;
......@@ -192,8 +149,8 @@ pulseaudio_mpris_get_available_players (PulseaudioMpris *mpris)
&error);
if (error)
{
g_critical ("Could not get a list of names registered on the session bus, %s",
error ? error->message : "no error given");
g_warning ("Could not get a list of names registered on the session bus, %s",
error ? error->message : "no error given");
g_clear_error (&error);
return NULL;
}
......@@ -226,6 +183,38 @@ pulseaudio_mpris_get_available_players (PulseaudioMpris *mpris)
static void
pulseaudio_mpris_player_connection_cb (PulseaudioMprisPlayer *player,
gchar *sender_name,
gpointer user_data)
{
PulseaudioMpris *mpris = user_data;
const gchar *player_dbus_name;
g_return_if_fail (IS_PULSEAUDIO_MPRIS (mpris));
player = g_object_ref (player);
player_dbus_name = pulseaudio_mpris_player_get_dbus_name (player);
if (!pulseaudio_mpris_player_is_connected (player))
{
g_hash_table_remove (mpris->players, pulseaudio_mpris_player_get_player (player));
g_hash_table_remove (mpris->players_by_dbus_name, player_dbus_name);
}
else if (G_LIKELY (!g_hash_table_contains (mpris->players_by_dbus_name, (gpointer) player_dbus_name)))
{
g_hash_table_insert (mpris->players_by_dbus_name, g_strdup (player_dbus_name), g_object_ref (player));
pulseaudio_config_add_known_player (mpris->config, player_dbus_name);
}
g_signal_emit (mpris, signals[UPDATE], 0, player_dbus_name);
g_object_unref (player);
}
static void
pulseaudio_mpris_player_update_cb (PulseaudioMprisPlayer *player,
gchar *sender_name,
......@@ -235,7 +224,7 @@ pulseaudio_mpris_player_update_cb (PulseaudioMprisPlayer *player,
g_return_if_fail (IS_PULSEAUDIO_MPRIS (mpris));
g_signal_emit (mpris, signals[UPDATE], 0, pulseaudio_mpris_player_get_player (player));
g_signal_emit (mpris, signals[UPDATE], 0, pulseaudio_mpris_player_get_dbus_name (player));
}
......@@ -248,43 +237,57 @@ pulseaudio_mpris_player_metadata_cb (PulseaudioMprisPlayer *player,
g_return_if_fail (IS_PULSEAUDIO_MPRIS (mpris));
g_signal_emit (mpris, signals[UPDATE], 0, pulseaudio_mpris_player_get_player (player));
g_signal_emit (mpris, signals[UPDATE], 0, pulseaudio_mpris_player_get_dbus_name (player));
}
static gboolean
pulseaudio_mpris_tick_cb (gpointer user_data)
static void
pulseaudio_mpris_manage_players (PulseaudioMpris *mpris)
{
PulseaudioMpris *mpris = user_data;
PulseaudioMprisPlayer *player;
gchar **players;
guint i = 0;
guint i;
guint num_players;
players = pulseaudio_mpris_get_available_players (mpris);
if (players == NULL)
return TRUE;
return;
for (i = 0; i < g_strv_length (players); i++)
num_players = g_strv_length (players);
for (i = 0; i < num_players; i++)
{
if (!g_hash_table_contains (mpris->players, players[i]))
{
player = pulseaudio_mpris_player_new (players[i]);
if (g_hash_table_contains (mpris->players, players[i]))
continue;
g_signal_connect (player, "connection", G_CALLBACK (pulseaudio_mpris_player_update_cb), mpris);
g_signal_connect (player, "playback-status", G_CALLBACK (pulseaudio_mpris_player_update_cb), mpris);
g_signal_connect (player, "metadata", G_CALLBACK (pulseaudio_mpris_player_metadata_cb), mpris);
player = pulseaudio_mpris_player_new (players[i]);
if (!player)
continue;
g_hash_table_insert (mpris->players, g_strdup (players[i]), player);
g_signal_connect (player, "connection", G_CALLBACK (pulseaudio_mpris_player_connection_cb), mpris);
g_signal_connect (player, "playback-status", G_CALLBACK (pulseaudio_mpris_player_update_cb), mpris);
g_signal_connect (player, "metadata", G_CALLBACK (pulseaudio_mpris_player_metadata_cb), mpris);
pulseaudio_config_add_mpris_player (mpris->config, players[i]);
}
g_hash_table_insert (mpris->players, g_strdup (players[i]), player);
}
if (players != NULL)
g_strfreev (players);
}
return TRUE;
static void
pulseaudio_mpris_changed_cb (GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
const gchar *interface_name,
const gchar *signal_name,
GVariant *parameters,
gpointer user_data)
{
PulseaudioMpris *mpris = user_data;
pulseaudio_mpris_manage_players (mpris);
}
......@@ -294,7 +297,6 @@ pulseaudio_mpris_get_player_snapshot (PulseaudioMpris *mpris,
const gchar *name,
gchar **title,
gchar **artist,
gboolean *is_running,
gboolean *is_playing,
gboolean *is_stopped,
gboolean *can_play,
......@@ -305,53 +307,42 @@ pulseaudio_mpris_get_player_snapshot (PulseaudioMpris *mpris,
GList **playlists)
{
PulseaudioMprisPlayer *player;
player = PULSEAUDIO_MPRIS_PLAYER (g_hash_table_lookup (mpris->players, name));
player = PULSEAUDIO_MPRIS_PLAYER (g_hash_table_lookup (mpris->players_by_dbus_name, name));
if (player == NULL || G_UNLIKELY (!pulseaudio_mpris_player_is_connected (player)))
return FALSE;
if (player != NULL)
*title = g_strdup (pulseaudio_mpris_player_get_title (player));
*artist = g_strdup (pulseaudio_mpris_player_get_artist (player));
*is_playing = pulseaudio_mpris_player_is_playing (player);
*is_stopped = pulseaudio_mpris_player_is_stopped (player);
*can_play = pulseaudio_mpris_player_can_play (player);
*can_pause = pulseaudio_mpris_player_can_pause (player);
*can_go_previous = pulseaudio_mpris_player_can_go_previous (player);
*can_go_next = pulseaudio_mpris_player_can_go_next (player);
*can_raise = pulseaudio_mpris_player_can_raise (player);
if (playlists)
*playlists = pulseaudio_mpris_player_get_playlists (player);
if (*title && **title == '\0')
{
if (pulseaudio_mpris_player_is_connected (player))
{
*title = g_strdup(pulseaudio_mpris_player_get_title (player));
*artist = g_strdup(pulseaudio_mpris_player_get_artist (player));
*is_running = TRUE;
*is_playing = pulseaudio_mpris_player_is_playing (player);
*is_stopped = pulseaudio_mpris_player_is_stopped (player);
*can_play = pulseaudio_mpris_player_can_play (player);
*can_pause = pulseaudio_mpris_player_can_pause (player);
*can_go_previous = pulseaudio_mpris_player_can_go_previous (player);
*can_go_next = pulseaudio_mpris_player_can_go_next (player);
*can_raise = pulseaudio_mpris_player_can_raise (player);
*playlists = pulseaudio_mpris_player_get_playlists (player);
}
else
{
*title = g_strdup(pulseaudio_mpris_player_get_player_title (player));
*artist = g_strdup("Not currently playing");
*is_running = FALSE;
*is_playing = FALSE;
*is_stopped = TRUE;
*can_play = FALSE;
*can_pause = FALSE;
*can_go_previous = FALSE;
*can_go_next = FALSE;
*can_raise = FALSE;
*playlists = NULL;
}
if (*title == NULL || g_strcmp0 (*title, "") == 0)
*title = g_strdup(pulseaudio_mpris_player_get_player_title (player));
return TRUE;
g_free (*title);
*title = NULL;
}
if (*title == NULL)
{
*title = g_strdup (pulseaudio_mpris_player_get_player_label (player));
}
return FALSE;
return TRUE;
}
static gboolean
pulseaudio_mpris_get_player_summary_from_desktop (const gchar *player_id,
gchar **name,
pulseaudio_mpris_get_player_summary_from_desktop (const gchar *player_name,
gchar **player_label,
gchar **icon_name,
gchar **full_path)
{
......@@ -359,11 +350,12 @@ pulseaudio_mpris_get_player_summary_from_desktop (const gchar *player_id,
gchar *file;
gchar *filename;
gchar *path;
gboolean ret = FALSE;
filename = find_desktop_entry (player_id);
filename = pulseaudio_mpris_player_find_desktop_entry (player_name);
if (filename == NULL)
{
return FALSE;
return ret;
}
file = g_strconcat("applications/", filename, NULL);
......@@ -372,41 +364,43 @@ pulseaudio_mpris_get_player_summary_from_desktop (const gchar *player_id,
key_file = g_key_file_new();
if (g_key_file_load_from_data_dirs (key_file, file, &path, G_KEY_FILE_NONE, NULL))
{
*name = g_key_file_get_string (key_file, "Desktop Entry", "Name", NULL);
*player_label = g_key_file_get_locale_string (key_file, "Desktop Entry", "Name", NULL, NULL);
if (G_UNLIKELY (*player_label == NULL))
*player_label = g_strdup (player_name);
*icon_name = g_key_file_get_string (key_file, "Desktop Entry", "Icon", NULL);
*full_path = g_strdup (path);
if (full_path)
*full_path = g_strdup (path);
g_free (path);
ret = TRUE;
}
g_key_file_free (key_file);
g_free (file);
return TRUE;
return ret;
}
gboolean
pulseaudio_mpris_get_player_summary (const gchar *player_id,
gchar **name,
pulseaudio_mpris_get_player_summary (const gchar *player_name,
gchar **player_label,
gchar **icon_name,
gchar **full_path)
{
PulseaudioMprisPlayer *player;
player = PULSEAUDIO_MPRIS_PLAYER (g_hash_table_lookup (mpris_instance->players, player_id));
player = PULSEAUDIO_MPRIS_PLAYER (g_hash_table_lookup (mpris_instance->players_by_dbus_name, player_name));
if (player == NULL)
return pulseaudio_mpris_get_player_summary_from_desktop (player_id, name, icon_name, full_path);
return pulseaudio_mpris_get_player_summary_from_desktop (player_name, player_label, icon_name, full_path);
*name = g_strdup (pulseaudio_mpris_player_get_player_title (player));
*icon_name = g_strdup (pulseaudio_mpris_player_get_icon_name (player));
*full_path = g_strdup (pulseaudio_mpris_player_get_full_path (player));
if (*full_path == NULL)
if (G_UNLIKELY (!pulseaudio_mpris_player_is_connected (player)))
return FALSE;
if (!pulseaudio_mpris_player_is_connected (player) && !pulseaudio_mpris_player_can_launch (player))
return FALSE;
*player_label = g_strdup (pulseaudio_mpris_player_get_player_label (player));
*icon_name = g_strdup (pulseaudio_mpris_player_get_icon_name (player));
if (full_path)
*full_path = g_strdup (pulseaudio_mpris_player_get_full_path (player));
return TRUE;
}
......@@ -422,15 +416,12 @@ pulseaudio_mpris_notify_player (PulseaudioMpris *mpris,
g_return_val_if_fail (IS_PULSEAUDIO_MPRIS (mpris), FALSE);
player = g_hash_table_lookup (mpris->players, name);
player = g_hash_table_lookup (mpris->players_by_dbus_name, name);
if (player != NULL)
if (player != NULL && G_LIKELY (pulseaudio_mpris_player_is_connected (player)))
{
if (pulseaudio_mpris_player_is_connected (player))
{
pulseaudio_mpris_player_call_player_method (player, message);
return TRUE;
}
pulseaudio_mpris_player_call_player_method (player, message, TRUE);
return TRUE;
}
return FALSE;
......@@ -443,25 +434,52 @@ pulseaudio_mpris_notify_any_player (PulseaudioMpris *mpris,
const gchar *message)
{
PulseaudioMprisPlayer *player;
PulseaudioMprisPlayer *recent_player = NULL;
GHashTableIter iter;
const gchar *key;
gint64 timestamp;
gint64 highest_timestamp = 0;
gboolean found = FALSE;
gboolean to_all;
g_return_val_if_fail(IS_PULSEAUDIO_MPRIS(mpris), FALSE);
g_hash_table_iter_init (&iter, mpris->players);
to_all = pulseaudio_config_get_multimedia_keys_to_all (mpris->config);
g_hash_table_iter_init (&iter, mpris->players_by_dbus_name);
while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer) &player))
{
if (player != NULL)
if (player == NULL)
continue;
if (G_UNLIKELY (!pulseaudio_mpris_player_is_connected (player)))
continue;
if (pulseaudio_config_player_ignored_lookup (mpris->config, key))
continue;
if (to_all)
{
pulseaudio_mpris_player_call_player_method (player, message, FALSE);
found = TRUE;
}
else
{
if (pulseaudio_mpris_player_is_connected(player))
timestamp = pulseaudio_mpris_player_get_timestamp (player);
if (timestamp > highest_timestamp || !recent_player)
{
pulseaudio_mpris_player_call_player_method(player, message);
found = TRUE;
highest_timestamp = timestamp;
recent_player = player;
}
}
}
if (recent_player)
{
pulseaudio_mpris_player_call_player_method (recent_player, message, FALSE);
found = TRUE;
}
return found;
}
......@@ -476,15 +494,12 @@ pulseaudio_mpris_activate_playlist (PulseaudioMpris *mpris,
g_return_val_if_fail(IS_PULSEAUDIO_MPRIS(mpris), FALSE);
player = g_hash_table_lookup(mpris->players, name);
player = g_hash_table_lookup(mpris->players_by_dbus_name, name);
if (player != NULL)
if (player != NULL && G_LIKELY (pulseaudio_mpris_player_is_connected (player)))
{
if (pulseaudio_mpris_player_is_connected (player))
{
pulseaudio_mpris_player_activate_playlist (player, playlist);
return TRUE;
}
pulseaudio_mpris_player_activate_playlist (player, playlist);
return TRUE;
}
return FALSE;
......@@ -495,8 +510,6 @@ pulseaudio_mpris_activate_playlist (PulseaudioMpris *mpris,
static void
pulseaudio_mpris_init (PulseaudioMpris *mpris)
{
mpris->config = NULL;
mpris->dbus_connection = NULL;
}
......@@ -508,11 +521,15 @@ pulseaudio_mpris_finalize (GObject *object)
mpris = PULSEAUDIO_MPRIS (object);
mpris->config = NULL;
mpris->dbus_connection = NULL;
mpris_instance = NULL;
if (mpris->dbus_signal_id != 0 && mpris->dbus_connection != NULL)
g_dbus_connection_signal_unsubscribe (mpris->dbus_connection, mpris->dbus_signal_id);
if (mpris->players != NULL)
g_hash_table_destroy (mpris->players);
if (mpris->players_by_dbus_name != NULL)
g_hash_table_destroy (mpris->players_by_dbus_name);
(*G_OBJECT_CLASS (pulseaudio_mpris_parent_class)->finalize) (object);
}
......@@ -528,20 +545,35 @@ pulseaudio_mpris_new (PulseaudioConfig *config)
g_return_val_if_fail (IS_PULSEAUDIO_CONFIG (config), NULL);
if (mpris_instance)
return NULL;
gconnection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &gerror);
if (gconnection == NULL)
{
g_message ("Failed to get session bus: %s", gerror->message);
g_error_free (gerror);
gerror = NULL;
return NULL;
}
mpris = g_object_new (TYPE_PULSEAUDIO_MPRIS, NULL);
mpris->config = config;
mpris->dbus_connection = gconnection;
mpris->players = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)g_free);
mpris->player_timer_id = g_timeout_add_seconds (1, pulseaudio_mpris_tick_cb, mpris);
mpris->players = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
mpris->players_by_dbus_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
mpris->dbus_signal_id = g_dbus_connection_signal_subscribe (gconnection,
"org.freedesktop.DBus",
"org.freedesktop.DBus",
"NameOwnerChanged",
"/org/freedesktop/DBus",
"org.mpris.MediaPlayer2",
G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE,
pulseaudio_mpris_changed_cb,
mpris,
NULL);
if (mpris->dbus_signal_id != 0)
pulseaudio_mpris_manage_players (mpris);
mpris_instance = mpris;
......
......@@ -39,13 +39,10 @@ typedef struct _PulseaudioMprisClass PulseaudioMprisCl
PulseaudioMpris *pulseaudio_mpris_new (PulseaudioConfig *config);
gchar **pulseaudio_mpris_get_available_players (PulseaudioMpris *mpris);
gboolean pulseaudio_mpris_get_player_snapshot (PulseaudioMpris *mpris,
const gchar *name,
gchar **title,
gchar **artist,
gboolean *is_running,
gboolean *is_playing,
gboolean *is_stopped,
gboolean *can_play,
......@@ -55,8 +52,8 @@ gboolean pulseaudio_mpris_get_player_snapshot (PulseaudioMpris
gboolean *can_raise,
GList **playlists);
gboolean pulseaudio_mpris_get_player_summary (const gchar *player,
gchar **name,
gboolean pulseaudio_mpris_get_player_summary (const gchar *player_name,
gchar **player_label,
gchar **icon_name,
gchar **full_path);
......
......@@ -39,9 +39,6 @@
#include <libxfce4util/libxfce4util.h>
#define SYNCHRONOUS "x-canonical-private-synchronous"
#define LAYOUT_ICON_ONLY "x-canonical-private-icon-only"
#include "pulseaudio-notify.h"
#define V_MUTED 0
......@@ -83,7 +80,6 @@ struct _PulseaudioNotify
PulseaudioVolume *volume;
PulseaudioButton *button;
gboolean gauge_notifications;
NotifyNotification *notification;
NotifyNotification *notification_mic;
......@@ -116,10 +112,6 @@ pulseaudio_notify_class_init (PulseaudioNotifyClass *klass)
static void
pulseaudio_notify_init (PulseaudioNotify *notify)
{
GList *caps_list;
GList *node;
notify->gauge_notifications = TRUE;
notify->notification = NULL;
notify->notification_mic = NULL;
notify->volume_changed_id = 0;
......@@ -127,15 +119,6 @@ pulseaudio_notify_init (PulseaudioNotify *notify)
notify_init ("Xfce volume control");
caps_list = notify_get_server_caps ();
if (caps_list)
{
node = g_list_find_custom (caps_list, LAYOUT_ICON_ONLY, (GCompareFunc) g_strcmp0);
if (!node)
notify->gauge_notifications = FALSE;
g_list_free (caps_list);
}
notify->notification = notify_notification_new ("xfce4-pulseaudio-plugin", NULL, NULL);
notify_notification_set_timeout (notify->notification, 2000);
notify_notification_set_hint (notify->notification, "transient", g_variant_new_boolean (TRUE));
......@@ -221,15 +204,9 @@ pulseaudio_notify_notify (PulseaudioNotify *notify, gboolean mic)
icon);
g_free (title);
if (notify->gauge_notifications)
{
notify_notification_set_hint (notification,
"value",
g_variant_new_int32(volume_i));
notify_notification_set_hint (notification,
"x-canonical-private-synchronous",
g_variant_new_string(""));
}
notify_notification_set_hint (notification,
"value",
g_variant_new_int32 (MIN (100, volume_i)));
if (!notify_notification_show (notification, &error))
{
......
......@@ -28,6 +28,9 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_XFCE_REVISION_H
#include "xfce-revision.h"
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
......@@ -35,7 +38,7 @@
#include <gtk/gtk.h>
#include <libxfce4util/libxfce4util.h>
#include <libxfce4ui/libxfce4ui.h>
#include <libxfce4panel/xfce-panel-plugin.h>
#include <libxfce4panel/libxfce4panel.h>
#include "pulseaudio-debug.h"
#include "pulseaudio-plugin.h"
......@@ -47,8 +50,10 @@
#include "pulseaudio-mpris.h"
#ifdef HAVE_KEYBINDER
#if defined (HAVE_KEYBINDER) && defined (GDK_WINDOWING_X11)
#define ENABLE_KEYBINDER 1
#include <keybinder.h>
#include <gdk/gdkx.h>
#define PULSEAUDIO_PLUGIN_RAISE_VOLUME_KEY "XF86AudioRaiseVolume"
#define PULSEAUDIO_PLUGIN_LOWER_VOLUME_KEY "XF86AudioLowerVolume"
......@@ -73,7 +78,11 @@ static void pulseaudio_plugin_configure_plugin (Xfce
static gboolean pulseaudio_plugin_size_changed (XfcePanelPlugin *plugin,
gint size);
#ifdef HAVE_KEYBINDER
static void pulseaudio_plugin_orientation_changed (XfcePanelPlugin *plugin,
GtkOrientation orientation);
static void pulseaudio_plugin_set_orientation (PulseaudioPlugin *pulseaudio_plugin);
static void pulseaudio_plugin_toggle_small (PulseaudioPlugin *pulseaudio_plugin);
#ifdef ENABLE_KEYBINDER
static void pulseaudio_plugin_bind_keys_cb (PulseaudioPlugin *pulseaudio_plugin,
PulseaudioConfig *pulseaudio_config);
static gboolean pulseaudio_plugin_bind_keys (PulseaudioPlugin *pulseaudio_plugin);
......@@ -149,6 +158,7 @@ pulseaudio_plugin_class_init (PulseaudioPluginClass *klass)
plugin_class->about = pulseaudio_plugin_show_about;
plugin_class->configure_plugin = pulseaudio_plugin_configure_plugin;
plugin_class->size_changed = pulseaudio_plugin_size_changed;
plugin_class->orientation_changed = pulseaudio_plugin_orientation_changed;
}
......@@ -180,15 +190,30 @@ pulseaudio_plugin_free_data (XfcePanelPlugin *plugin)
{
PulseaudioPlugin *pulseaudio_plugin = PULSEAUDIO_PLUGIN (plugin);
#ifdef HAVE_KEYBINDER
if (pulseaudio_plugin->volume)
g_object_unref (pulseaudio_plugin->volume);
if (pulseaudio_plugin->dialog)
g_object_unref (pulseaudio_plugin->dialog);
#ifdef ENABLE_KEYBINDER
/* release keybindings */
pulseaudio_plugin_unbind_keys (pulseaudio_plugin);
pulseaudio_plugin_unbind_multimedia_keys (pulseaudio_plugin);
#endif
#ifdef HAVE_MPRIS2
if (pulseaudio_plugin->mpris)
g_object_unref (pulseaudio_plugin->mpris);
#endif
#ifdef HAVE_LIBCANBERRA
if (pulseaudio_plugin->canberra)
ca_context_destroy (pulseaudio_plugin->canberra);
#endif
#ifdef HAVE_LIBNOTIFY
if (pulseaudio_plugin->notify)
g_object_unref (pulseaudio_plugin->notify);
#endif
}
......@@ -238,6 +263,7 @@ pulseaudio_plugin_show_about (XfcePanelPlugin *plugin)
"Viktor Odintsev <zakhams@gmail.com>",
"Matthieu Mota <matthieumota@gmail.com>",
"Sean Davis <bluesabre@xfce.org>",
"Błażej Szczygieł <mumei6102@gmail.com>",
NULL
};
......@@ -246,11 +272,11 @@ pulseaudio_plugin_show_about (XfcePanelPlugin *plugin)
gtk_show_about_dialog (NULL,
"logo-icon-name", "xfce4-pulseaudio-plugin",
"license", xfce_get_license_text (XFCE_LICENSE_TEXT_GPL),
"version", PACKAGE_VERSION,
"version", VERSION_FULL,
"program-name", PACKAGE_NAME,
"comments", _("Adjust the audio volume of the PulseAudio sound system"),
"website", "https://docs.xfce.org/panel-plugins/xfce4-pulseaudio-plugin",
"copyright", _("Copyright \xc2\xa9 2014-2022 Andrzej Radecki et al.\n"),
"copyright", "Copyright \xc2\xa9 2014-" COPYRIGHT_YEAR " The Xfce development team",
"authors", auth,
NULL);
}
......@@ -277,28 +303,76 @@ pulseaudio_plugin_size_changed (XfcePanelPlugin *plugin,
/* The plugin only occupies a single row */
size /= xfce_panel_plugin_get_nrows(plugin);
#if LIBXFCE4PANEL_CHECK_VERSION (4, 13, 0)
icon_size = xfce_panel_plugin_get_icon_size (plugin);
#else
// fall-back for older panel versions
icon_size = size;
icon_size -= 4;
if (icon_size < 24)
icon_size = 16;
else if (icon_size < 32)
icon_size = 24;
else if (icon_size < 36)
icon_size = 32;
#endif
pulseaudio_button_set_size (pulseaudio_plugin->button, size, icon_size);
pulseaudio_plugin_set_orientation (pulseaudio_plugin);
return TRUE;
}
#ifdef HAVE_KEYBINDER
static void
pulseaudio_plugin_orientation_changed (XfcePanelPlugin *plugin,
GtkOrientation orientation)
{
PulseaudioPlugin *pulseaudio_plugin = PULSEAUDIO_PLUGIN (plugin);
pulseaudio_plugin_set_orientation (pulseaudio_plugin);
}
static void
pulseaudio_plugin_set_orientation (PulseaudioPlugin *pulseaudio_plugin)
{
GtkOrientation orientation;
gint nrows;
gint size;
gint icon_size;
orientation = xfce_panel_plugin_get_orientation (XFCE_PANEL_PLUGIN (pulseaudio_plugin));
nrows = xfce_panel_plugin_get_nrows (XFCE_PANEL_PLUGIN (pulseaudio_plugin));
size = xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (pulseaudio_plugin));
icon_size = xfce_panel_plugin_get_icon_size (XFCE_PANEL_PLUGIN (pulseaudio_plugin));
if (size > icon_size * 2 + XFCE_PANEL_PLUGIN_ICON_PADDING)
{
if (orientation == GTK_ORIENTATION_VERTICAL)
pulseaudio_button_set_orientation (pulseaudio_plugin->button, GTK_ORIENTATION_HORIZONTAL);
else
pulseaudio_button_set_orientation (pulseaudio_plugin->button, GTK_ORIENTATION_VERTICAL);
}
else
{
pulseaudio_button_set_orientation (pulseaudio_plugin->button, orientation);
}
pulseaudio_button_set_size (pulseaudio_plugin->button, size / nrows, icon_size);
}
static void
pulseaudio_plugin_toggle_small (PulseaudioPlugin *pulseaudio_plugin)
{
gboolean recording = pulseaudio_volume_get_recording (pulseaudio_plugin->volume);
gboolean rec_indicator_persistent = pulseaudio_config_get_rec_indicator_persistent (pulseaudio_plugin->config);
if (recording || rec_indicator_persistent)
{
xfce_panel_plugin_set_small (XFCE_PANEL_PLUGIN (pulseaudio_plugin), FALSE);
}
else
{
xfce_panel_plugin_set_small (XFCE_PANEL_PLUGIN (pulseaudio_plugin), TRUE);
}
}
#ifdef ENABLE_KEYBINDER
static void
pulseaudio_plugin_bind_keys_cb (PulseaudioPlugin *pulseaudio_plugin,
PulseaudioConfig *pulseaudio_config)
......@@ -316,14 +390,14 @@ pulseaudio_plugin_bind_keys_cb (PulseaudioPlugin *pulseaudio_plugin,
static gboolean
pulseaudio_plugin_bind_keys (PulseaudioPlugin *pulseaudio_plugin)
{
gboolean success;
gboolean success = TRUE;
g_return_val_if_fail (IS_PULSEAUDIO_PLUGIN (pulseaudio_plugin), FALSE);
pulseaudio_debug ("Grabbing volume control keys");
success = (keybinder_bind (PULSEAUDIO_PLUGIN_LOWER_VOLUME_KEY, pulseaudio_plugin_volume_key_pressed, pulseaudio_plugin) &&
keybinder_bind (PULSEAUDIO_PLUGIN_RAISE_VOLUME_KEY, pulseaudio_plugin_volume_key_pressed, pulseaudio_plugin) &&
keybinder_bind (PULSEAUDIO_PLUGIN_MUTE_KEY, pulseaudio_plugin_mute_pressed, pulseaudio_plugin) &&
keybinder_bind (PULSEAUDIO_PLUGIN_MIC_MUTE_KEY, pulseaudio_plugin_mic_mute_pressed, pulseaudio_plugin));
success &= keybinder_bind (PULSEAUDIO_PLUGIN_LOWER_VOLUME_KEY, pulseaudio_plugin_volume_key_pressed, pulseaudio_plugin);
success &= keybinder_bind (PULSEAUDIO_PLUGIN_RAISE_VOLUME_KEY, pulseaudio_plugin_volume_key_pressed, pulseaudio_plugin);
success &= keybinder_bind (PULSEAUDIO_PLUGIN_MUTE_KEY, pulseaudio_plugin_mute_pressed, pulseaudio_plugin);
success &= keybinder_bind (PULSEAUDIO_PLUGIN_MIC_MUTE_KEY, pulseaudio_plugin_mic_mute_pressed, pulseaudio_plugin);
if (!success)
g_warning ("Could not have grabbed volume control keys. Is another volume control application (xfce4-volumed) running?");
......@@ -352,6 +426,7 @@ pulseaudio_plugin_volume_key_pressed (const char *keystring,
PulseaudioPlugin *pulseaudio_plugin = PULSEAUDIO_PLUGIN (user_data);
gdouble volume = pulseaudio_volume_get_volume (pulseaudio_plugin->volume);
gdouble volume_step = pulseaudio_config_get_volume_step (pulseaudio_plugin->config) / 100.0;
gboolean notify = pulseaudio_volume_get_show_notifications (pulseaudio_plugin->volume, VOLUME_NOTIFICATIONS_OUTPUT);
pulseaudio_debug ("%s pressed", keystring);
......@@ -359,14 +434,14 @@ pulseaudio_plugin_volume_key_pressed (const char *keystring,
pulseaudio_volume_set_volume (pulseaudio_plugin->volume, MIN (volume + volume_step, MAX (volume, 1.0)));
#ifdef HAVE_LIBNOTIFY
/* Also send notification when volume is already at 100% */
if (volume > 1.0 - 2e-3)
if (notify && volume > 1.0 - 2e-3)
pulseaudio_notify_volume_changed (pulseaudio_plugin->notify, TRUE, pulseaudio_plugin->volume);
#endif
} else if (strcmp (keystring, PULSEAUDIO_PLUGIN_LOWER_VOLUME_KEY) == 0) {
pulseaudio_volume_set_volume (pulseaudio_plugin->volume, MAX (0.0, volume - volume_step));
#ifdef HAVE_LIBNOTIFY
/* Also send notification when volume is already at 0% */
if (volume < 2e-3)
if (notify && volume < 2e-3)
pulseaudio_notify_volume_changed (pulseaudio_plugin->notify, TRUE, pulseaudio_plugin->volume);
#endif
}
......@@ -417,14 +492,14 @@ pulseaudio_plugin_bind_multimedia_keys_cb (PulseaudioPlugin *pulseaudio_plu
static gboolean
pulseaudio_plugin_bind_multimedia_keys (PulseaudioPlugin *pulseaudio_plugin)
{
gboolean success;
gboolean success = TRUE;
g_return_val_if_fail (IS_PULSEAUDIO_PLUGIN (pulseaudio_plugin), FALSE);
pulseaudio_debug ("Grabbing multimedia control keys");
success = (keybinder_bind (PULSEAUDIO_PLUGIN_PLAY_KEY, pulseaudio_plugin_play_key_pressed, pulseaudio_plugin) &&
keybinder_bind (PULSEAUDIO_PLUGIN_STOP_KEY, pulseaudio_plugin_stop_key_pressed, pulseaudio_plugin) &&
keybinder_bind (PULSEAUDIO_PLUGIN_PREV_KEY, pulseaudio_plugin_prev_key_pressed, pulseaudio_plugin) &&
keybinder_bind (PULSEAUDIO_PLUGIN_NEXT_KEY, pulseaudio_plugin_next_key_pressed, pulseaudio_plugin));
success &= keybinder_bind (PULSEAUDIO_PLUGIN_PLAY_KEY, pulseaudio_plugin_play_key_pressed, pulseaudio_plugin);
success &= keybinder_bind (PULSEAUDIO_PLUGIN_STOP_KEY, pulseaudio_plugin_stop_key_pressed, pulseaudio_plugin);
success &= keybinder_bind (PULSEAUDIO_PLUGIN_PREV_KEY, pulseaudio_plugin_prev_key_pressed, pulseaudio_plugin);
success &= keybinder_bind (PULSEAUDIO_PLUGIN_NEXT_KEY, pulseaudio_plugin_next_key_pressed, pulseaudio_plugin);
if (!success)
g_warning ("Could not have grabbed multimedia control keys.");
......@@ -529,40 +604,37 @@ pulseaudio_plugin_construct (XfcePanelPlugin *plugin)
xfce_panel_plugin_menu_show_configure (plugin);
xfce_panel_plugin_menu_show_about (plugin);
xfce_panel_plugin_set_small (plugin, TRUE);
/* setup transation domain */
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
/* initialize xfconf */
pulseaudio_plugin->config = pulseaudio_config_new (xfce_panel_plugin_get_property_base (plugin));
g_signal_connect_swapped (pulseaudio_plugin->config, "notify::rec-indicator-persistent", G_CALLBACK (pulseaudio_plugin_toggle_small), pulseaudio_plugin);
/* instantiate preference dialog builder */
pulseaudio_plugin->dialog = pulseaudio_dialog_new (pulseaudio_plugin->config);
#ifdef HAVE_KEYBINDER
/* Initialize libkeybinder */
keybinder_init ();
g_signal_connect_swapped (G_OBJECT (pulseaudio_plugin->config), "notify::enable-keyboard-shortcuts",
G_CALLBACK (pulseaudio_plugin_bind_keys_cb), pulseaudio_plugin);
g_signal_connect_swapped (G_OBJECT (pulseaudio_plugin->config), "notify::enable-multimedia-keys",
G_CALLBACK (pulseaudio_plugin_bind_multimedia_keys_cb), pulseaudio_plugin);
if (pulseaudio_config_get_enable_keyboard_shortcuts (pulseaudio_plugin->config))
pulseaudio_plugin_bind_keys(pulseaudio_plugin);
else
pulseaudio_plugin_unbind_keys(pulseaudio_plugin);
if (pulseaudio_config_get_enable_multimedia_keys (pulseaudio_plugin->config))
pulseaudio_plugin_bind_multimedia_keys(pulseaudio_plugin);
else
pulseaudio_plugin_unbind_multimedia_keys(pulseaudio_plugin);
#ifdef ENABLE_KEYBINDER
if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
{
/* Initialize libkeybinder */
keybinder_init ();
g_signal_connect_swapped (G_OBJECT (pulseaudio_plugin->config), "notify::enable-keyboard-shortcuts",
G_CALLBACK (pulseaudio_plugin_bind_keys_cb), pulseaudio_plugin);
g_signal_connect_swapped (G_OBJECT (pulseaudio_plugin->config), "notify::enable-multimedia-keys",
G_CALLBACK (pulseaudio_plugin_bind_multimedia_keys_cb), pulseaudio_plugin);
pulseaudio_plugin_bind_keys_cb (pulseaudio_plugin, NULL);
pulseaudio_plugin_bind_multimedia_keys_cb (pulseaudio_plugin, NULL);
}
#endif
/* volume controller */
pulseaudio_plugin->volume = pulseaudio_volume_new (pulseaudio_plugin,
pulseaudio_plugin->config);
g_signal_connect_swapped (pulseaudio_plugin->volume, "recording_changed", G_CALLBACK (pulseaudio_plugin_toggle_small), pulseaudio_plugin);
/* initialize mpris support */
#ifdef HAVE_MPRIS2
pulseaudio_plugin->mpris = pulseaudio_mpris_new (pulseaudio_plugin->config);
......
This diff is collapsed.
......@@ -41,8 +41,6 @@ PulseaudioVolume *pulseaudio_volume_new (PulseaudioPlu
PulseaudioConfig *config);
gboolean pulseaudio_volume_get_connected (PulseaudioVolume *volume);
gboolean pulseaudio_volume_get_sink_connected (PulseaudioVolume *volume);
gboolean pulseaudio_volume_get_source_connected (PulseaudioVolume *volume);
gdouble pulseaudio_volume_get_volume (PulseaudioVolume *volume);
void pulseaudio_volume_set_volume (PulseaudioVolume *volume,
......@@ -56,6 +54,7 @@ void pulseaudio_volume_set_muted (PulseaudioVol
void pulseaudio_volume_toggle_muted (PulseaudioVolume *volume);
gdouble pulseaudio_volume_get_volume_mic (PulseaudioVolume *volume);
gdouble pulseaudio_volume_get_base_volume_mic (PulseaudioVolume *volume);
void pulseaudio_volume_set_volume_mic (PulseaudioVolume *volume,
gdouble vol);
......@@ -66,7 +65,8 @@ void pulseaudio_volume_toggle_muted_mic (PulseaudioVol
GList *pulseaudio_volume_get_output_list (PulseaudioVolume *volume);
gchar *pulseaudio_volume_get_output_by_name (PulseaudioVolume *volume,
gchar *name);
const gchar *name,
gboolean *available);
const gchar *pulseaudio_volume_get_default_output (PulseaudioVolume *volume);
void pulseaudio_volume_set_default_output (PulseaudioVolume *volume,
const gchar *name,
......@@ -74,11 +74,14 @@ void pulseaudio_volume_set_default_output (PulseaudioVol
GList *pulseaudio_volume_get_input_list (PulseaudioVolume *volume);
gchar *pulseaudio_volume_get_input_by_name (PulseaudioVolume *volume,
gchar *name);
const gchar *name,
gboolean *available);
const gchar *pulseaudio_volume_get_default_input (PulseaudioVolume *volume);
void pulseaudio_volume_set_default_input (PulseaudioVolume *volume,
const gchar *name,
gboolean make_default);
gboolean pulseaudio_volume_get_show_notifications (PulseaudioVolume *volume,
guint direction);
G_END_DECLS
......
[Xfce Panel]
Type=X-XFCE-PanelPlugin
Encoding=UTF-8
_Name=PulseAudio Plugin
_Comment=Adjust the audio volume of the PulseAudio sound system
Name=PulseAudio Plugin
Comment=Adjust the audio volume of the PulseAudio sound system
Icon=xfce4-pulseaudio-plugin
X-XFCE-Module=pulseaudio-plugin
X-XFCE-Internal=FALSE
......
This diff is collapsed.
......@@ -25,56 +25,35 @@
*/
#ifndef _SCALE_MENU_ITEM_H_
#define _SCALE_MENU_ITEM_H_
#ifndef _XFPA_SCALE_MENU_ITEM_H_
#define _XFPA_SCALE_MENU_ITEM_H_
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define TYPE_SCALE_MENU_ITEM (scale_menu_item_get_type ())
#define SCALE_MENU_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SCALE_MENU_ITEM, ScaleMenuItem))
#define SCALE_MENU_ITEM_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TYPE_SCALE_MENU_ITEM, ScaleMenuItemClass))
#define IS_SCALE_MENU_ITEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SCALE_MENU_ITEM))
#define IS_SCALE_MENU_ITEM_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), TYPE_SCALE_MENU_ITEM))
#define SCALE_MENU_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_SCALE_MENU_ITEM, ScaleMenuItemClass))
#define XFPA_TYPE_SCALE_MENU_ITEM (xfpa_scale_menu_item_get_type ())
#ifndef glib_autoptr_clear_GtkImageMenuItem
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GtkImageMenuItem, g_object_unref)
#endif
G_DECLARE_FINAL_TYPE (XfpaScaleMenuItem, xfpa_scale_menu_item, XFPA, SCALE_MENU_ITEM, GtkImageMenuItem)
GtkWidget *xfpa_scale_menu_item_new_with_range (gdouble min,
gdouble max,
gdouble step,
gdouble base);
typedef struct _ScaleMenuItem ScaleMenuItem;
typedef struct _ScaleMenuItemClass ScaleMenuItemClass;
typedef struct _ScaleMenuItemPrivate ScaleMenuItemPrivate;
gdouble xfpa_scale_menu_item_get_value (XfpaScaleMenuItem *item);
void xfpa_scale_menu_item_set_value (XfpaScaleMenuItem *item,
gdouble value);
struct _ScaleMenuItem
{
GtkImageMenuItem parent_instance;
ScaleMenuItemPrivate *priv;
};
struct _ScaleMenuItemClass
{
GtkImageMenuItemClass parent_class;
};
GType scale_menu_item_get_type (void) G_GNUC_CONST;
GtkWidget *scale_menu_item_new_with_range (gdouble min,
gdouble max,
gdouble step);
gdouble scale_menu_item_get_value (ScaleMenuItem *item);
void scale_menu_item_set_value (ScaleMenuItem *item,
gdouble value);
gboolean scale_menu_item_get_muted (ScaleMenuItem *item);
void scale_menu_item_set_muted (ScaleMenuItem *item,
gboolean muted);
void scale_menu_item_set_base_icon_name (ScaleMenuItem *item,
const gchar *base_icon_name);
gboolean xfpa_scale_menu_item_get_muted (XfpaScaleMenuItem *item);
void xfpa_scale_menu_item_set_muted (XfpaScaleMenuItem *item,
gboolean muted);
void xfpa_scale_menu_item_set_base_icon_name (XfpaScaleMenuItem *item,
const gchar *base_icon_name);
G_END_DECLS
#endif /* _SCALE_MENU_ITEM_H_ */
#endif /* _XFPA_SCALE_MENU_ITEM_H_ */
# Generated by https://gitlab.xfce.org/infra/transifex
ar
be
bg
ca
cs
da
de
el
en_AU
en_CA
en_GB
es
et
eu
fi
fr
ga
gl
he
hr
hu
hy_AM
hye
id
ie
is
it
ja
kk
ko
lt
ms
nb
nl
oc
pl
pt_BR
pt
ro
ru
sk
sl
sq
sr
sv
th
tr
uk
vi
zh_CN
zh_TW
# Makefile variables for PO directory in any package using GNU gettext.
#
# Copyright (C) 2003-2019 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation gives
# unlimited permission to use, copy, distribute, and modify it.
# Usually the message domain is the same as the package name.
DOMAIN = $(PACKAGE)
# These two variables depend on the location of this directory.
subdir = po
top_builddir = ..
# These options get passed to xgettext.
XGETTEXT_OPTIONS = --from-code=UTF-8 --keyword=_ --keyword=N_ \
--keyword=C_:1c,2 --keyword=NC_:1c,2 --keyword=g_dngettext:2,3 \
--add-comments
# This is the copyright holder that gets inserted into the header of the
# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
# package. (Note that the msgstr strings, extracted from the package's
# sources, belong to the copyright holder of the package.) Translators are
# expected to transfer the copyright for their translations to this person
# or entity, or to disclaim their copyright. The empty string stands for
# the public domain; in this case the translators are expected to disclaim
# their copyright.
COPYRIGHT_HOLDER = The Xfce development team.
# This tells whether or not to prepend "GNU " prefix to the package
# name that gets inserted into the header of the $(DOMAIN).pot file.
# Possible values are "yes", "no", or empty. If it is empty, try to
# detect it automatically by scanning the files in $(top_srcdir) for
# "GNU packagename" string.
PACKAGE_GNU = no
# This is the email address or URL to which the translators shall report
# bugs in the untranslated strings:
# - Strings which are not entire sentences, see the maintainer guidelines
# in the GNU gettext documentation, section 'Preparing Strings'.
# - Strings which use unclear terms or require additional context to be
# understood.
# - Strings which make invalid assumptions about notation of date, time or
# money.
# - Pluralisation problems.
# - Incorrect English spelling.
# - Incorrect formatting.
# It can be your email address, or a mailing list address where translators
# can write to without being subscribed, or the URL of a web page through
# which the translators can contact you.
MSGID_BUGS_ADDRESS =
# This is the list of locale categories, beyond LC_MESSAGES, for which the
# message catalogs shall be used. It is usually empty.
EXTRA_LOCALE_CATEGORIES =
# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
# context. Possible values are "yes" and "no". Set this to yes if the
# package uses functions taking also a message context, like pgettext(), or
# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
USE_MSGCTXT = no
# These options get passed to msgmerge.
# Useful options are in particular:
# --previous to keep previous msgids of translated messages,
# --quiet to reduce the verbosity.
MSGMERGE_OPTIONS =
# These options get passed to msginit.
# If you want to disable line wrapping when writing PO files, add
# --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and
# MSGINIT_OPTIONS.
MSGINIT_OPTIONS =
# This tells whether or not to regenerate a PO file when $(DOMAIN).pot
# has changed. Possible values are "yes" and "no". Set this to no if
# the POT file is checked in the repository and the version control
# program ignores timestamps.
PO_DEPENDS_ON_POT = no
# This tells whether or not to forcibly update $(DOMAIN).pot and
# regenerate PO files on "make dist". Possible values are "yes" and
# "no". Set this to no if the POT file and PO files are maintained
# externally.
DIST_DEPENDS_ON_UPDATE_PO = no
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.