[pulseaudio-commits] 2 commits - src/mainwindow.h src/pavuapplication.cc src/pavuapplication.h src/pavucontrol.cc src/pavucontrol.h

Tanu Kaskinen tanuk at kemper.freedesktop.org
Thu Nov 2 08:53:20 UTC 2017


 src/mainwindow.h       |    2 ++
 src/pavuapplication.cc |   23 +++++++++--------------
 src/pavuapplication.h  |    5 +----
 src/pavucontrol.cc     |    2 +-
 src/pavucontrol.h      |    4 +++-
 5 files changed, 16 insertions(+), 20 deletions(-)

New commits:
commit 36d82f23aa3cab49e28fc1c77d6ac4b2ed702643
Author: Tanu Kaskinen <tanuk at iki.fi>
Date:   Wed Nov 1 13:47:06 2017 +0200

    remove unnecessary Window -> MainWindow casting
    
    mainwindow.h and pavucontrol.h include each other, which makes it
    necessary to declare some types before the include directives.

diff --git a/src/mainwindow.h b/src/mainwindow.h
index f45bf9a..b56cf73 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -21,6 +21,8 @@
 #ifndef mainwindow_h
 #define mainwindow_h
 
+class MainWindow;
+
 #include "pavucontrol.h"
 #include <pulse/ext-stream-restore.h>
 #if HAVE_EXT_DEVICE_RESTORE_API
diff --git a/src/pavuapplication.cc b/src/pavuapplication.cc
index b67ec04..c8e5edd 100644
--- a/src/pavuapplication.cc
+++ b/src/pavuapplication.cc
@@ -42,7 +42,7 @@ MainWindow* PavuApplication::create_window()
     m = pa_glib_mainloop_new(g_main_context_default());
     g_assert(m);
 
-    MainWindow* pavucontrol_window = (MainWindow *)pavucontrol_get_window(m, maximize, retry, tab);
+    MainWindow* pavucontrol_window = pavucontrol_get_window(m, maximize, retry, tab);
 
     pavucontrol_window->signal_hide().connect(
                      sigc::bind<Gtk::Window*>(sigc::mem_fun(*this,
diff --git a/src/pavucontrol.cc b/src/pavucontrol.cc
index fc7499c..32935d8 100644
--- a/src/pavucontrol.cc
+++ b/src/pavucontrol.cc
@@ -625,7 +625,7 @@ gboolean connect_to_pulse(gpointer userdata) {
     return false;
 }
 
-Gtk::Window* pavucontrol_get_window(pa_glib_mainloop *m, bool maximize, bool _retry, int _tab_number) {
+MainWindow* pavucontrol_get_window(pa_glib_mainloop *m, bool maximize, bool _retry, int _tab_number) {
 
     MainWindow* mainWindow = NULL;
 
diff --git a/src/pavucontrol.h b/src/pavucontrol.h
index 31fee6b..a5ecb03 100644
--- a/src/pavucontrol.h
+++ b/src/pavucontrol.h
@@ -69,8 +69,10 @@ enum SourceType {
     SOURCE_MONITOR,
 };
 
+#include "mainwindow.h"
+
 pa_context* get_context(void);
 void show_error(const char *txt);
 
-Gtk::Window* pavucontrol_get_window(pa_glib_mainloop *m, bool maximize, bool retry, int tab_number);
+MainWindow* pavucontrol_get_window(pa_glib_mainloop *m, bool maximize, bool retry, int tab_number);
 #endif

commit 107a8dd3055fa11680c9a1f2318f71b5a3d93b23
Author: Tanu Kaskinen <tanuk at iki.fi>
Date:   Wed Nov 1 13:47:05 2017 +0200

    remove unnecessary RefPtr wrapping of PavuApplication
    
    There's no need for reference counting of PavuApplication.

diff --git a/src/pavuapplication.cc b/src/pavuapplication.cc
index 3fc874f..b67ec04 100644
--- a/src/pavuapplication.cc
+++ b/src/pavuapplication.cc
@@ -33,11 +33,6 @@
 PavuApplication::PavuApplication() : Gtk::Application("org.pulseaudio.pavucontrol", Gio::ApplicationFlags::APPLICATION_HANDLES_COMMAND_LINE) {
 }
 
-Glib::RefPtr<PavuApplication> PavuApplication::create() {
-    return Glib::RefPtr<PavuApplication>(new PavuApplication());
-
-}
-
 /*
  * Create the main window and connect its "on_hide_window" signal to our cleanup
  * function
@@ -112,7 +107,7 @@ static bool get_arg_value(const Glib::RefPtr<Glib::VariantDict>& options, const
  * This is executed in the first-running process.
  */
 int on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line,
-                    Glib::RefPtr<PavuApplication>& app)
+                    PavuApplication *app)
 {
     const auto options = command_line->get_options_dict();
 
@@ -141,26 +136,26 @@ int main(int argc, char *argv[]) {
     signal(SIGPIPE, SIG_IGN);
 
     /* Create the application */
-    auto app = PavuApplication::create();
+    auto app = PavuApplication();
 
     /* Add command-line options */
-    app->add_main_option_entry(
+    app.add_main_option_entry(
         Gio::Application::OptionType::OPTION_TYPE_INT,
         "tab", 't',
         _("Select a specific tab on load."),
         _("number"));
 
-    app->add_main_option_entry(
+    app.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(
+    app.add_main_option_entry(
         Gio::Application::OptionType::OPTION_TYPE_BOOL,
         "maximize", 'm',
         _("Maximize the window."));
 
-    app->add_main_option_entry(
+    app.add_main_option_entry(
         Gio::Application::OptionType::OPTION_TYPE_BOOL,
         "version", 'v',
         _("Show version."));
@@ -168,7 +163,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);
+    app.signal_command_line().connect(sigc::bind(sigc::ptr_fun(&on_command_line), &app), false);
 
     /* Run the application.
      * In the first launched instance, this will return when its window is
@@ -177,5 +172,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 app.run(argc, argv);
 }
diff --git a/src/pavuapplication.h b/src/pavuapplication.h
index 8ff3f35..4df722f 100644
--- a/src/pavuapplication.h
+++ b/src/pavuapplication.h
@@ -25,11 +25,8 @@
 #include "mainwindow.h"
 
 class PavuApplication : public Gtk::Application {
-protected:
-    PavuApplication();
-
 public:
-    static Glib::RefPtr<PavuApplication> create();
+    PavuApplication();
 
     /* Main window */
     MainWindow *mainWindow;



More information about the pulseaudio-commits mailing list