changeset 4544:084dbc8d23da

removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
author mf0102 <0102@gmx.at>
date Mon, 12 May 2008 23:01:06 +0200
parents ed94ac6182df
children c9be7256db08
files src/audacious/auddrct.c src/audacious/dbus.c src/audacious/main.c src/audacious/main.h src/audacious/ui_main_evlisteners.c src/audacious/ui_playlist_evlisteners.c
diffstat 6 files changed, 116 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/auddrct.c	Mon May 12 19:31:11 2008 +0200
+++ b/src/audacious/auddrct.c	Mon May 12 23:01:06 2008 +0200
@@ -25,10 +25,6 @@
 #include "main.h"
 #include "input.h"
 #include "playback.h"
-#include "ui_main.h"
-#include "ui_playlist.h"
-#include "ui_equalizer.h"
-#include "ui_jumptotrack.h"
 #include "auddrct.h"
 #include "playlist.h"
 
@@ -43,17 +39,15 @@
 void
 drct_eject ( void )
 {
-    if (has_x11_connection)
-        mainwin_eject_pushed();
-    return;
+    gboolean play_button = FALSE;
+    hook_call("filebrowser show", &play_button);
 }
 
 void
 drct_jtf_show ( void )
 {
-    if (has_x11_connection)
-        ui_jump_to_track();
-    return;
+    gboolean show = TRUE;
+    hook_call("ui jump to track show", &show);
 }
 
 gboolean
@@ -65,9 +59,7 @@
 void
 drct_main_win_toggle ( gboolean show )
 {
-    if (has_x11_connection)
-        mainwin_show(show);
-    return;
+    hook_call("mainwin show", &show);
 }
 
 gboolean
@@ -79,9 +71,7 @@
 void
 drct_eq_win_toggle ( gboolean show )
 {
-    if (has_x11_connection)
-        equalizerwin_show(show);
-    return;
+    hook_call("equalizerwin show", &show);
 }
 
 gboolean
@@ -93,13 +83,7 @@
 void
 drct_pl_win_toggle ( gboolean show )
 {
-    if (has_x11_connection) {
-        if (show)
-            playlistwin_show();
-        else
-            playlistwin_hide();
-    }
-    return;
+    hook_call("playlistwin show", &show);
 }
 
 void drct_activate(void)
--- a/src/audacious/dbus.c	Mon May 12 19:31:11 2008 +0200
+++ b/src/audacious/dbus.c	Mon May 12 23:01:06 2008 +0200
@@ -33,19 +33,13 @@
 
 #include <math.h>
 #include "main.h"
-#include "ui_equalizer.h"
-#include "ui_main.h"
 #include "input.h"
 #include "playback.h"
 #include "playlist.h"
-#include "ui_playlist.h"
-#include "ui_preferences.h"
 #include "tuple.h"
-#include "ui_jumptotrack.h"
 #include "strings.h"
-#include "ui_credits.h"
+#include "ui_equalizer.h"
 #include "ui_skin.h"
-#include "ui_fileopener.h"
 
 static DBusGConnection *dbus_conn = NULL;
 static guint signals[LAST_SIG] = { 0 };
@@ -523,23 +517,19 @@
 }
 
 gboolean audacious_rc_eject(RemoteObject *obj, GError **error) {
-    if (has_x11_connection)
-        mainwin_eject_pushed();
+    drct_eject();
     return TRUE;
 }
 
 gboolean audacious_rc_main_win_visible(RemoteObject *obj,
                                        gboolean *is_main_win, GError **error) {
     *is_main_win = cfg.player_visible;
-    g_message("main win %s\n", (cfg.player_visible? "visible" : "hidden"));
     return TRUE;
 }
 
 gboolean audacious_rc_show_main_win(RemoteObject *obj, gboolean show,
                                     GError **error) {
-    g_message("%s main win\n", (show? "showing": "hiding"));
-    if (has_x11_connection)
-        mainwin_show(show);
+    drct_main_win_toggle(show);
     return TRUE;
 }
 
@@ -551,8 +541,7 @@
 
 gboolean audacious_rc_show_equalizer(RemoteObject *obj, gboolean show,
                                      GError **error) {
-    if (has_x11_connection)
-        equalizerwin_show(show);
+    drct_eq_win_toggle(show);
     return TRUE;
 }
 
@@ -564,12 +553,7 @@
 
 gboolean audacious_rc_show_playlist(RemoteObject *obj, gboolean show,
                                     GError **error) {
-    if (has_x11_connection) {
-        if (show)
-            playlistwin_show();
-        else
-            playlistwin_hide();
-    }
+    drct_pl_win_toggle(show);
     return TRUE;
 }
 
@@ -821,42 +805,27 @@
 
 /* New on Oct 5 */
 gboolean audacious_rc_show_prefs_box(RemoteObject *obj, gboolean show, GError **error) {
-    if (has_x11_connection) {
-        if (show)
-            show_prefs_window();
-        else
-            hide_prefs_window();
-    }
+    hook_call("prefswin show", &show);
     return TRUE;
 }
+
 gboolean audacious_rc_show_about_box(RemoteObject *obj, gboolean show, GError **error) {
-    if (has_x11_connection) {
-        if (show)
-            show_about_window();
-        else
-            hide_about_window();
-    }
+    hook_call("aboutwin show", &show);
     return TRUE;
 }
 
 gboolean audacious_rc_show_jtf_box(RemoteObject *obj, gboolean show, GError **error) {
-    if (has_x11_connection) {
-        if (show)
-            ui_jump_to_track();
-        else
-            ui_jump_to_track_hide();
-    }
+    hook_call("ui jump to track show", &show);
     return TRUE;
 }
 
 gboolean audacious_rc_show_filebrowser(RemoteObject *obj, gboolean show, GError **error)
 {
-    if (has_x11_connection) {
-        if (show)
-            run_filebrowser(FALSE);
-        else
-            hide_filebrowser();
-    }
+    gboolean play_button = FALSE;
+    if (show)
+        hook_call("filebrowser show", &play_button);
+    else
+        hook_call("filebrowser hide", NULL);
     return TRUE;
 }
 
@@ -873,14 +842,15 @@
     return TRUE;
 }
 
+/* TODO: these skin functions should be removed when skin functionality
+ * disappears --mf0102 */
 gboolean audacious_rc_get_skin(RemoteObject *obj, gchar **skin, GError **error) {
     *skin = g_strdup(aud_active_skin->path);
     return TRUE;
 }
 
 gboolean audacious_rc_set_skin(RemoteObject *obj, gchar *skin, GError **error) {
-    if (has_x11_connection == TRUE)
-        aud_active_skin_load(skin);
+    aud_active_skin_load(skin);
     return TRUE;
 }
 
@@ -890,9 +860,7 @@
 }
 
 gboolean audacious_rc_toggle_aot(RemoteObject *obj, gboolean ontop, GError **error) {
-    if (has_x11_connection) {
-        mainwin_set_always_on_top(ontop);
-    }
+    hook_call("mainwin set always on top", &ontop);
     return TRUE;
 }
 
--- a/src/audacious/main.c	Mon May 12 19:31:11 2008 +0200
+++ b/src/audacious/main.c	Mon May 12 23:01:06 2008 +0200
@@ -89,7 +89,6 @@
 #include "icons-stock.h"
 #include "images/audacious_player.xpm"
 
-gboolean has_x11_connection = FALSE;  /* do we have an X11 connection? */
 static const gchar *application_name = N_("Audacious");
 
 struct _AudCmdLineOpt {
@@ -789,8 +788,6 @@
 
         hint_set_always(cfg.always_on_top);
 
-        has_x11_connection = TRUE;
-
         resume_playback_on_startup();
         
         gtk_main();
--- a/src/audacious/main.h	Mon May 12 19:31:11 2008 +0200
+++ b/src/audacious/main.h	Mon May 12 23:01:06 2008 +0200
@@ -76,8 +76,6 @@
 
 extern gchar *aud_paths[];
 
-extern gboolean has_x11_connection;
-
 extern GCond *cond_scan;
 extern GMutex *mutex_scan;
 #if defined(USE_DBUS) && defined(_AUDACIOUS_CORE)
--- a/src/audacious/ui_main_evlisteners.c	Mon May 12 19:31:11 2008 +0200
+++ b/src/audacious/ui_main_evlisteners.c	Mon May 12 23:01:06 2008 +0200
@@ -29,12 +29,16 @@
 #include "playlist_evmessages.h"
 #include "visualization.h"
 
+#include "ui_credits.h"
+#include "ui_equalizer.h"
+#include "ui_fileopener.h"
+#include "ui_jumptotrack.h"
 #include "ui_main.h"
-#include "ui_equalizer.h"
+#include "ui_playlist.h"
+#include "ui_preferences.h"
 #include "ui_skinned_playstatus.h"
 #include "ui_skinned_textbox.h"
 #include "ui_skinned_window.h"
-#include "ui_playlist.h"
 
 static gint song_info_timeout_source = 0;
 static gint update_vis_timeout_source = 0;
@@ -191,6 +195,71 @@
 }
 
 static void
+ui_main_evlistener_mainwin_set_always_on_top(gpointer hook_data, gpointer user_data)
+{
+    gboolean *ontop = (gboolean*)hook_data;
+    mainwin_set_always_on_top(*ontop);
+}
+
+static void
+ui_main_evlistener_mainwin_show(gpointer hook_data, gpointer user_data)
+{
+    gboolean *show = (gboolean*)hook_data;
+    mainwin_show(*show);
+}
+
+static void
+ui_main_evlistener_equalizerwin_show(gpointer hook_data, gpointer user_data)
+{
+    gboolean *show = (gboolean*)hook_data;
+    equalizerwin_show(*show);
+}
+
+static void
+ui_main_evlistener_prefswin_show(gpointer hook_data, gpointer user_data)
+{
+    gboolean *show = (gboolean*)hook_data;
+    if (*show == TRUE)
+        show_prefs_window();
+    else
+        hide_prefs_window();
+}
+
+static void
+ui_main_evlistener_aboutwin_show(gpointer hook_data, gpointer user_data)
+{
+    gboolean *show = (gboolean*)hook_data;
+    if (*show == TRUE)
+        show_about_window();
+    else
+        hide_about_window();
+}
+
+
+static void
+ui_main_evlistener_ui_jump_to_track_show(gpointer hook_data, gpointer user_data)
+{
+    gboolean *show = (gboolean*)hook_data;
+    if (*show == TRUE)
+        ui_jump_to_track();
+    else
+        ui_jump_to_track_hide();
+}
+
+static void
+ui_main_evlistener_filebrowser_show(gpointer hook_data, gpointer user_data)
+{
+    gboolean *play_button = (gboolean*)hook_data;
+    run_filebrowser(*play_button);
+}
+
+static void
+ui_main_evlistener_filebrowser_hide(gpointer hook_data, gpointer user_data)
+{
+    hide_filebrowser();
+}
+
+static void
 ui_main_evlistener_config_save(gpointer hook_data, gpointer user_data)
 {
     ConfigDb *db = (ConfigDb *) hook_data;
@@ -221,6 +290,14 @@
     hook_associate("playback play file", ui_main_evlistener_playback_play_file, NULL);
     hook_associate("playlist end reached", ui_main_evlistener_playlist_end_reached, NULL);
     hook_associate("playlist info change", ui_main_evlistener_playlist_info_change, NULL);
+    hook_associate("mainwin set always on top", ui_main_evlistener_mainwin_set_always_on_top, NULL);
+    hook_associate("mainwin show", ui_main_evlistener_mainwin_show, NULL);
+    hook_associate("equalizerwin show", ui_main_evlistener_equalizerwin_show, NULL);
+    hook_associate("prefswin show", ui_main_evlistener_prefswin_show, NULL);
+    hook_associate("aboutwin show", ui_main_evlistener_aboutwin_show, NULL);
+    hook_associate("ui jump to track show", ui_main_evlistener_ui_jump_to_track_show, NULL);
+    hook_associate("filebrowser show", ui_main_evlistener_filebrowser_show, NULL);
+    hook_associate("filebrowser hide", ui_main_evlistener_filebrowser_hide, NULL);
     hook_associate("config save", ui_main_evlistener_config_save, NULL);
 }
 
--- a/src/audacious/ui_playlist_evlisteners.c	Mon May 12 19:31:11 2008 +0200
+++ b/src/audacious/ui_playlist_evlisteners.c	Mon May 12 23:01:06 2008 +0200
@@ -37,8 +37,18 @@
     playlist_manager_update();
 }
 
+static void
+ui_playlist_evlistener_playlistwin_show(gpointer hook_data, gpointer user_data)
+{
+    gboolean *show = (gboolean*)hook_data;
+    if (*show == TRUE)
+        playlistwin_show();
+    else
+        playlistwin_hide();
+}
+
 void ui_playlist_evlistener_init(void)
 {
-    hook_associate("playlist update",
-                   ui_playlist_evlistener_playlist_update, NULL);
+    hook_associate("playlist update", ui_playlist_evlistener_playlist_update, NULL);
+    hook_associate("playlistwin show", ui_playlist_evlistener_playlistwin_show, NULL);
 }