changeset 4717:d59d0c490a61

hookify urlopener
author Tomasz Mon <desowin@gmail.com>
date Wed, 09 Jul 2008 16:08:45 +0200
parents 8e62ba58ea6e
children 7e0685ceeb86 1a13d88b72f3
files src/audacious/legacy/ui_main.c src/audacious/legacy/ui_main.h src/audacious/legacy/ui_main_evlisteners.c src/audacious/legacy/ui_playlist.c src/audacious/ui_urlopener.c src/audacious/ui_urlopener.h
diffstat 6 files changed, 56 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/legacy/ui_main.c	Wed Jul 09 11:41:31 2008 +0200
+++ b/src/audacious/legacy/ui_main.c	Wed Jul 09 16:08:45 2008 +0200
@@ -72,7 +72,6 @@
 #include "ui_playlist.h"
 #include "ui_preferences.h"
 #include "ui_skinselector.h"
-#include "ui_urlopener.h"
 #include "util.h"
 #include "visualization.h"
 
@@ -1089,30 +1088,6 @@
 }
 
 static void
-on_add_url_add_clicked(GtkWidget * widget,
-                       GtkWidget * entry)
-{
-    const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry));
-    if (text && *text)
-        playlist_add_url(playlist_get_active(), text);
-}
-
-static void
-on_add_url_ok_clicked(GtkWidget * widget,
-                      GtkWidget * entry)
-{
-    Playlist *playlist = playlist_get_active();
-
-    const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry));
-    if (text && *text)
-    {
-        playlist_clear(playlist);
-        playlist_add_url(playlist, text);
-        playback_initiate();
-    }
-}
-
-static void
 on_visibility_warning_toggle(GtkToggleButton *tbt, gpointer unused)
 {
     cfg.warn_about_win_visibility = !gtk_toggle_button_get_active(tbt);
@@ -1236,26 +1211,6 @@
     g_free(theme);
 }
 
-void
-mainwin_show_add_url_window(void)
-{
-    static GtkWidget *url_window = NULL;
-
-    if (!url_window) {
-        url_window =
-            util_add_url_dialog_new(_("Enter location to play:"),
-                                    G_CALLBACK(on_add_url_ok_clicked),
-                                    G_CALLBACK(on_add_url_add_clicked));
-        gtk_window_set_transient_for(GTK_WINDOW(url_window),
-                                     GTK_WINDOW(mainwin));
-        g_signal_connect(url_window, "destroy",
-                         G_CALLBACK(gtk_widget_destroyed),
-                         &url_window);
-    }
-
-    gtk_window_present(GTK_WINDOW(url_window));
-}
-
 static void
 check_set( GtkActionGroup * action_group ,
            const gchar * action_name ,
@@ -1761,7 +1716,7 @@
             run_filebrowser(FALSE);
             break;
         case MAINWIN_GENERAL_PLAYLOCATION:
-            mainwin_show_add_url_window();
+            hook_call("urlopener show", NULL);
             break;
         case MAINWIN_GENERAL_FILEINFO:
             ui_fileinfo_show_current(playlist);
@@ -2729,7 +2684,7 @@
 void
 action_play_location( void )
 {
-    mainwin_show_add_url_window();
+    hook_call("urlopener show", NULL);
 }
 
 void
--- a/src/audacious/legacy/ui_main.h	Wed Jul 09 11:41:31 2008 +0200
+++ b/src/audacious/legacy/ui_main.h	Wed Jul 09 16:08:45 2008 +0200
@@ -155,7 +155,6 @@
 void mainwin_repeat_pushed(gboolean toggled);
 void mainwin_disable_seekbar(void);
 void mainwin_set_title(const gchar * text);
-void mainwin_show_add_url_window(void);
 void mainwin_minimize_cb(void);
 void mainwin_general_menu_callback(gpointer cb_data,
                                    guint action,
--- a/src/audacious/legacy/ui_main_evlisteners.c	Wed Jul 09 11:41:31 2008 +0200
+++ b/src/audacious/legacy/ui_main_evlisteners.c	Wed Jul 09 16:08:45 2008 +0200
@@ -32,6 +32,7 @@
 #include "ui_credits.h"
 #include "ui_equalizer.h"
 #include "ui_fileopener.h"
+#include "ui_urlopener.h"
 #include "ui_jumptotrack.h"
 #include "ui_main.h"
 #include "ui_playlist.h"
@@ -443,6 +444,12 @@
                   cfg.equalizer_bands);
 }
 
+static void
+ui_main_evlistener_urlopener_show(gpointer hook_data, gpointer user_data)
+{
+    show_add_url_window();
+}
+
 void
 ui_main_evlistener_init(void)
 {
@@ -468,6 +475,7 @@
     hook_associate("filebrowser hide", ui_main_evlistener_filebrowser_hide, NULL);
     hook_associate("visualization timeout", ui_main_evlistener_visualization_timeout, NULL);
     hook_associate("config save", ui_main_evlistener_config_save, NULL);
+    hook_associate("urlopener show", ui_main_evlistener_urlopener_show, NULL);
 
     hook_associate("equalizer changed", ui_main_evlistener_equalizer_changed, NULL);
 }
--- a/src/audacious/legacy/ui_playlist.c	Wed Jul 09 11:41:31 2008 +0200
+++ b/src/audacious/legacy/ui_playlist.c	Wed Jul 09 16:08:45 2008 +0200
@@ -1201,7 +1201,7 @@
         break;
     case GDK_Insert:
         if (event->state & GDK_MOD1_MASK)
-            mainwin_show_add_url_window();
+            hook_call("urlopener show", NULL);
         else
             playlistwin_show_filebrowser();
         break;
@@ -1802,7 +1802,7 @@
 void
 action_playlist_add_url(void)
 {
-    mainwin_show_add_url_window();
+    hook_call("urlopener show", NULL);
 }
 
 void
--- a/src/audacious/ui_urlopener.c	Wed Jul 09 11:41:31 2008 +0200
+++ b/src/audacious/ui_urlopener.c	Wed Jul 09 16:08:45 2008 +0200
@@ -156,3 +156,46 @@
 
     return win;
 }
+
+static void
+on_add_url_add_clicked(GtkWidget * widget,
+                       GtkWidget * entry)
+{
+    const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry));
+    if (text && *text)
+        playlist_add_url(playlist_get_active(), text);
+}
+
+static void
+on_add_url_ok_clicked(GtkWidget * widget,
+                      GtkWidget * entry)
+{
+    Playlist *playlist = playlist_get_active();
+
+    const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry));
+    if (text && *text)
+    {
+        playlist_clear(playlist);
+        playlist_add_url(playlist, text);
+        playback_initiate();
+    }
+}
+
+void
+show_add_url_window(void)
+{
+    static GtkWidget *url_window = NULL;
+
+    if (!url_window) {
+        url_window =
+            util_add_url_dialog_new(_("Enter location to play:"),
+                                    G_CALLBACK(on_add_url_ok_clicked),
+                                    G_CALLBACK(on_add_url_add_clicked));
+
+        g_signal_connect(url_window, "destroy",
+                         G_CALLBACK(gtk_widget_destroyed),
+                         &url_window);
+    }
+
+    gtk_window_present(GTK_WINDOW(url_window));
+}
--- a/src/audacious/ui_urlopener.h	Wed Jul 09 11:41:31 2008 +0200
+++ b/src/audacious/ui_urlopener.h	Wed Jul 09 16:08:45 2008 +0200
@@ -39,6 +39,7 @@
 
 GtkWidget *util_add_url_dialog_new(const gchar * caption, GCallback ok_func,
                                    GCallback enqueue_func);
+void show_add_url_window(void);
 
 G_END_DECLS