Migrate away from deprecated Gtk interfaces

This was accomplished by building with -DGTKMM_DISABLE_DEPRECATED.
This commit is contained in:
Felipe Sateler 2019-12-28 12:39:38 -03:00 committed by Tanu Kaskinen
parent b10f0d9623
commit 2840825519
10 changed files with 46 additions and 35 deletions

View File

@ -41,7 +41,7 @@ AC_TYPE_SIGNAL
AC_HEADER_STDC
AX_CXX_COMPILE_STDCXX_11
PKG_CHECK_MODULES(GUILIBS, [ gtkmm-3.0 >= 3.0 sigc++-2.0 libcanberra-gtk3 >= 0.16 ])
PKG_CHECK_MODULES(GUILIBS, [ gtkmm-3.0 >= 3.22 sigc++-2.0 libcanberra-gtk3 >= 0.16 ])
AC_SUBST(GUILIBS_CFLAGS)
AC_SUBST(GUILIBS_LIBS)

View File

@ -38,7 +38,7 @@ public:
Gtk::Label *channelLabel;
Gtk::Label *volumeLabel;
Gtk::HScale *volumeScale;
Gtk::Scale *volumeScale;
int channel;
MinimalStreamWidget *minimalStreamWidget;

View File

@ -227,7 +227,7 @@ void DeviceWidget::prepareMenu() {
bool DeviceWidget::onContextTriggerEvent(GdkEventButton* event) {
if (GDK_BUTTON_PRESS == event->type && 3 == event->button) {
contextMenu.popup(event->button, event->time);
contextMenu.popup_at_pointer((GdkEvent*)event);
return true;
}
@ -259,8 +259,8 @@ void DeviceWidget::renamePopup() {
x->get_widget("renameText", renameText);
renameText->set_text(description);
dialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
dialog->add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
dialog->add_button("_Cancel", Gtk::RESPONSE_CANCEL);
dialog->add_button("_OK", Gtk::RESPONSE_OK);
dialog->set_default_response(Gtk::RESPONSE_OK);
if (Gtk::RESPONSE_OK == dialog->run()) {
pa_operation* o;

View File

@ -95,11 +95,11 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
x->get_widget("notebook", notebook);
x->get_widget("showVolumeMetersCheckButton", showVolumeMetersCheckButton);
cardsVBox->set_reallocate_redraws(true);
sourcesVBox->set_reallocate_redraws(true);
streamsVBox->set_reallocate_redraws(true);
recsVBox->set_reallocate_redraws(true);
sinksVBox->set_reallocate_redraws(true);
sourcesVBox->signal_size_allocate().connect([this](Gdk::Rectangle _unused){ sourcesVBox->queue_draw(); });
cardsVBox->signal_size_allocate().connect([this](Gdk::Rectangle _unused){ cardsVBox->queue_draw(); });
streamsVBox->signal_size_allocate().connect([this](Gdk::Rectangle _unused){ streamsVBox->queue_draw(); });
recsVBox->signal_size_allocate().connect([this](Gdk::Rectangle _unused){ recsVBox->queue_draw(); });
sinksVBox->signal_size_allocate().connect([this](Gdk::Rectangle _unused){ sinksVBox->queue_draw(); });
sinkInputTypeComboBox->set_active((int) showSinkInputType);
sourceOutputTypeComboBox->set_active((int) showSourceOutputType);
@ -222,7 +222,7 @@ bool MainWindow::on_key_press_event(GdkEventKey* event) {
case GDK_KEY_Q:
case GDK_KEY_w:
case GDK_KEY_q:
Gtk::Main::quit();
this->get_application()->quit();
return true;
}
}

View File

@ -30,6 +30,14 @@
#include "pavucontrol.h"
#include "mainwindow.h"
static PavuApplication globalInstance;
PavuApplication&
PavuApplication::get_instance()
{
return globalInstance;
}
PavuApplication::PavuApplication() :
Gtk::Application("org.pulseaudio.pavucontrol", Gio::ApplicationFlags::APPLICATION_HANDLES_COMMAND_LINE),
mainWindow(NULL),
@ -143,26 +151,26 @@ int main(int argc, char *argv[]) {
signal(SIGPIPE, SIG_IGN);
/* Create the application */
PavuApplication app;
globalInstance = PavuApplication();
/* Add command-line options */
app.add_main_option_entry(
globalInstance.add_main_option_entry(
Gio::Application::OptionType::OPTION_TYPE_INT,
"tab", 't',
_("Select a specific tab on load."),
_("number"));
app.add_main_option_entry(
globalInstance.add_main_option_entry(
Gio::Application::OptionType::OPTION_TYPE_BOOL,
"retry", 'r',
_("Retry forever if pa quits (every 5 seconds)."));
app.add_main_option_entry(
globalInstance.add_main_option_entry(
Gio::Application::OptionType::OPTION_TYPE_BOOL,
"maximize", 'm',
_("Maximize the window."));
app.add_main_option_entry(
globalInstance.add_main_option_entry(
Gio::Application::OptionType::OPTION_TYPE_BOOL,
"version", 'v',
_("Show version."));
@ -170,7 +178,7 @@ int main(int argc, char *argv[]) {
/* Connect to the "on_command_line" signal which is fired
* when the application receives command-line arguments
*/
app.signal_command_line().connect(sigc::bind(sigc::ptr_fun(&on_command_line), &app), false);
globalInstance.signal_command_line().connect(sigc::bind(sigc::ptr_fun(&on_command_line), &globalInstance), false);
/* Run the application.
* In the first launched instance, this will return when its window is
@ -179,5 +187,5 @@ int main(int argc, char *argv[]) {
* Handling a new request consists of presenting the existing window (and
* optionally, select a tab).
*/
return app.run(argc, argv);
return globalInstance.run(argc, argv);
}

View File

@ -37,6 +37,8 @@ public:
gint32 tab;
bool version;
static PavuApplication& get_instance();
protected:
// Override default signal handlers:
void on_activate() override;

View File

@ -40,6 +40,7 @@
#include "sourceoutputwidget.h"
#include "rolewidget.h"
#include "mainwindow.h"
#include "pavuapplication.h"
static pa_context* context = NULL;
static pa_mainloop_api* api = NULL;
@ -56,7 +57,7 @@ void show_error(const char *txt) {
Gtk::MessageDialog dialog(buf, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
dialog.run();
Gtk::Main::quit();
PavuApplication::get_instance().quit();
}
static void dec_outstanding(MainWindow *w) {
@ -571,7 +572,7 @@ void context_state_callback(pa_context *c, void *userdata) {
case PA_CONTEXT_TERMINATED:
default:
Gtk::Main::quit();
w->get_application()->quit();
return;
}
}
@ -613,7 +614,7 @@ gboolean connect_to_pulse(gpointer userdata) {
else {
if(!retry) {
reconnect_timeout = -1;
Gtk::Main::quit();
w->get_application()->quit();
} else {
g_debug(_("Connection failed, attempting reconnect"));
reconnect_timeout = 5;

View File

@ -425,10 +425,10 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkTable" id="encodingSelect">
<object class="GtkGrid" id="encodingSelect">
<property name="can_focus">False</property>
<property name="n_rows">2</property>
<property name="n_columns">3</property>
<property name="row_homogeneous">True</property>
<property name="column_homogeneous">True</property>
<child>
<object class="GtkCheckButton" id="encodingFormatPCM">
<property name="label" translatable="yes">PCM</property>
@ -439,6 +439,10 @@
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="encodingFormatAC3">
@ -450,7 +454,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
@ -462,8 +466,8 @@
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
@ -475,8 +479,8 @@
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
@ -489,9 +493,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
@ -504,9 +506,7 @@
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
</object>

View File

@ -46,7 +46,7 @@ public:
#if HAVE_EXT_DEVICE_RESTORE_API
encodingList encodings[PAVU_NUM_ENCODINGS];
Gtk::Table *encodingSelect;
Gtk::Grid *encodingSelect;
#endif
virtual void onMuteToggleButton();

View File

@ -66,7 +66,7 @@ void StreamWidget::init(MainWindow* mainWindow) {
bool StreamWidget::onContextTriggerEvent(GdkEventButton* event) {
if (GDK_BUTTON_PRESS == event->type && 3 == event->button) {
contextMenu.popup(event->button, event->time);
contextMenu.popup_at_pointer((GdkEvent*)event);
return true;
}
return false;