-
Notifications
You must be signed in to change notification settings - Fork 42
Added wireplumber mixer widget #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This reverts commit 81bfaf3.
|
Actually, the audio sources controls seem very broken. Re-marking as draft. |
|
Should be good !'m not running into bugs in my own use anymore. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thank for your PR! Please consider fixing the issues.
src/panel/widgets/wireplumber.hpp
Outdated
|
|
||
| static std::vector<WayfireWireplumber*> widgets; | ||
|
|
||
| static void init_wp(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not define static functions and objects in headers. These functions should go into wireplumber.cpp.
Also I don't like the global variable above...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I don't like the global variable above...
As far as i see, the alternative is connect the signals with the WayfireWireplumber as user data, for each widget ? Is that better or worse ?
src/panel/widgets/wireplumber.cpp
Outdated
| #include <gtkmm.h> | ||
| #include <iostream> | ||
| #include <glibmm.h> | ||
| #include "gio/gio.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use <...> for library headers.
| mute_conn = button.signal_toggled().connect( | ||
| [this, id] () | ||
| { | ||
| GVariantBuilder gvb = G_VARIANT_BUILDER_INIT(G_VARIANT_TYPE_VARDICT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Glib::Variant instead of C glib functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I’m sorry but for some reason i can’t seem to figure it out… Do you know how to do it ?
My best shot is something like this :
auto dict = Glib::VariantDict::create();
dict->insert_value_variant("mute", Glib::Variant<bool>::create(button.get_active()));
gboolean res FALSE;
g_signal_emit_by_name(WpCommon::mixer_api, "set-volume", id, dict->gobj(), &res);But it aborts on a type info check assertion and i seem to phenomenally fail at looking anything up.
src/panel/widgets/wireplumber.cpp
Outdated
| return; | ||
| } | ||
|
|
||
| std::map<VolumeLevel, std::string> icon_name_from_state = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
icon_name_from_state can be made static const.
src/panel/widgets/wireplumber.cpp
Outdated
|
|
||
| WfWpControl*WfWpControl::copy() | ||
| { | ||
| WfWpControl *copy = new WfWpControl(object, parent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not return objects by raw pointers. Either use std::unique_ptr or return by value.
Also why don't you just use the default copy constructor? Ah, because there are callbacks that store a pointer to the object. Then you probably want to make the object non-movable.
src/panel/widgets/wireplumber.cpp
Outdated
| if (g_strcmp0(type, "Audio/Sink") == 0) | ||
| { | ||
| which_box = &(widget->sinks_box); | ||
| control = new WfWpControlDevice(obj, widget); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't manage memory with new/delete.
Probably objects_to_control should own the objects through std::unique_ptr.
src/panel/widgets/wireplumber.cpp
Outdated
| { | ||
| // adds a new widget to the appropriate section | ||
|
|
||
| WpPipewireObject *obj = (WpPipewireObject*)object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto *
src/panel/widgets/wireplumber.cpp
Outdated
|
|
||
| WpPipewireObject *obj = (WpPipewireObject*)object; | ||
|
|
||
| const gchar *type = wp_pipewire_object_get_property(obj, PW_KEY_MEDIA_CLASS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::string_view
src/panel/widgets/wireplumber.cpp
Outdated
| WfOption<std::string> str_wp_right_click_action{"panel/wp_right_click_action"}; | ||
| WfOption<std::string> str_wp_middle_click_action{"panel/wp_middle_click_action"}; | ||
|
|
||
| if ((std::string)str_face_choice == (std::string)"last_change") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't cast a string constant to std::string for comparison. std::string has operator== with const char *.
Also please use .value() method of WfOption instead casting it to std::string: it looks better and would allow to optimize unnecessary copy if value() would return a reference instead of copy (it currently doesn't, but I think we should fix it).
src/panel/widgets/wireplumber.cpp
Outdated
| reload_config(); | ||
|
|
||
| // boxes hierarchy and labeling | ||
| auto r1 = Gtk::Orientation::HORIZONTAL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use such aliases. It decreases code readability.
Feel free to do so if you find it better. We already do that for window-list, simply create a subdirectory and place all files in it. |
The widget allows for control of the indivual volumes for sinks, sources and output streams, as well as selection of the default for the first two.
Upon changes to a volume, it pops up an interactible slider for the volume that changed.
Has mute on middle click, scroll to change volume and reduced view on right click
Has the following settings :