changeset 2422:b31111934cd3 trunk

[svn] - break out the URL opener UI code
author nenolod
date Sat, 27 Jan 2007 04:37:49 -0800
parents 74ec16ef847b
children 3a41eba0ef5d
files ChangeLog src/audacious/Makefile src/audacious/ui_fileopener.c src/audacious/ui_main.c src/audacious/ui_urlopener.c src/audacious/ui_urlopener.h src/audacious/util.c src/audacious/util.h
diffstat 8 files changed, 219 insertions(+), 109 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Jan 27 04:32:08 2007 -0800
+++ b/ChangeLog	Sat Jan 27 04:37:49 2007 -0800
@@ -1,3 +1,11 @@
+2007-01-27 12:32:08 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [3852]
+  - fix accidental removal of xmms_show_message
+  
+  trunk/src/audacious/util.c |  113 +++++++++++++++++++++++++++++++++++++++++++++
+  1 file changed, 113 insertions(+)
+
+
 2007-01-27 12:07:46 +0000  Michael Farber <01mf02@gmail.com>
   revision [3850]
   Removed util.* from libaudacious
--- a/src/audacious/Makefile	Sat Jan 27 04:32:08 2007 -0800
+++ b/src/audacious/Makefile	Sat Jan 27 04:37:49 2007 -0800
@@ -83,6 +83,7 @@
 	ui_playlist.c \
 	ui_preferences.c \
 	ui_skinselector.c \
+	ui_urlopener.c \
 	urldecode.c \
 	util.c \
 	vfs_buffer.c \
--- a/src/audacious/ui_fileopener.c	Sat Jan 27 04:32:08 2007 -0800
+++ b/src/audacious/ui_fileopener.c	Sat Jan 27 04:37:49 2007 -0800
@@ -130,19 +130,20 @@
     if (cfg.filesel_path)
         gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(chooser),
                                             cfg.filesel_path);
-    gtk_box_pack_start(GTK_BOX(vbox), chooser, TRUE, TRUE, 5);
+    gtk_box_pack_start(GTK_BOX(vbox), chooser, TRUE, TRUE, 3);
 
     hbox = gtk_hbox_new(TRUE, 0);
-    gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
+    gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);
 
     toggle = gtk_check_button_new_with_label(toggle_text);
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle),
                                  cfg.close_dialog_open ? TRUE : FALSE);
-    gtk_box_pack_start(GTK_BOX(hbox), toggle, TRUE, TRUE, 5);
+    gtk_box_pack_start(GTK_BOX(hbox), toggle, TRUE, TRUE, 3);
 
     bbox = gtk_hbutton_box_new();
     gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
-    gtk_box_pack_end(GTK_BOX(hbox), bbox, TRUE, TRUE, 5);
+    gtk_box_set_spacing(GTK_BOX(bbox), 6);
+    gtk_box_pack_end(GTK_BOX(hbox), bbox, TRUE, TRUE, 3);
 
     close_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
     action_button = gtk_button_new_from_stock(action_stock);
--- a/src/audacious/ui_main.c	Sat Jan 27 04:32:08 2007 -0800
+++ b/src/audacious/ui_main.c	Sat Jan 27 04:37:49 2007 -0800
@@ -77,6 +77,7 @@
 #include "ui_playlist.h"
 #include "ui_preferences.h"
 #include "ui_skinselector.h"
+#include "ui_urlopener.h"
 #include "strings.h"
 #include "util.h"
 #include "visualization.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audacious/ui_urlopener.c	Sat Jan 27 04:37:49 2007 -0800
@@ -0,0 +1,161 @@
+/*  Audacious - Cross-platform multimedia player
+ *  Copyright (C) 2005-2007  Audacious development team
+ *
+ *  Based on BMP:
+ *  Copyright (C) 2003-2004  BMP development team.
+ *
+ *  Based on XMMS:
+ *  Copyright (C) 1998-2003  XMMS development team.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; under version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#define NEED_GLADE
+#include "util.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glade/glade.h>
+#include <gtk/gtk.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "platform/smartinclude.h"
+#include <errno.h>
+
+#ifdef HAVE_FTS_H
+#  include <fts.h>
+#endif
+
+#include "glade.h"
+#include "input.h"
+#include "main.h"
+#include "playback.h"
+#include "strings.h"
+#include "ui_playlist.h"
+
+#ifdef USE_CHARDET
+    #include "../librcd/librcd.h"
+#ifdef HAVE_UDET
+    #include <libudet_c.h>
+#endif
+#endif
+
+#define URL_HISTORY_MAX_SIZE 30
+
+static void
+util_add_url_callback(GtkWidget * widget,
+                      GtkEntry * entry)
+{
+    const gchar *text;
+
+    text = gtk_entry_get_text(entry);
+    if (g_list_find_custom(cfg.url_history, text, (GCompareFunc) strcasecmp))
+        return;
+
+    cfg.url_history = g_list_prepend(cfg.url_history, g_strdup(text));
+
+    while (g_list_length(cfg.url_history) > URL_HISTORY_MAX_SIZE) {
+        GList *node = g_list_last(cfg.url_history);
+        g_free(node->data);
+        cfg.url_history = g_list_delete_link(cfg.url_history, node);
+    }
+}
+
+GtkWidget *
+util_add_url_dialog_new(const gchar * caption, GCallback ok_func,
+    GCallback enqueue_func)
+{
+    GtkWidget *win, *vbox, *bbox, *enqueue, *ok, *cancel, *combo, *entry, 
+          *label;
+    GList *url;
+
+    win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_window_set_title(GTK_WINDOW(win), _("Add/Open URL Dialog"));
+    gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_DIALOG);
+    gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER);
+    gtk_window_set_default_size(GTK_WINDOW(win), 400, -1);
+    gtk_container_set_border_width(GTK_CONTAINER(win), 12);
+
+    vbox = gtk_vbox_new(FALSE, 10);
+    gtk_container_add(GTK_CONTAINER(win), vbox);
+
+    label = gtk_label_new(caption);
+    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
+
+    combo = gtk_combo_box_entry_new_text();
+    gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0);
+
+    entry = gtk_bin_get_child(GTK_BIN(combo));
+    gtk_window_set_focus(GTK_WINDOW(win), entry);
+    gtk_entry_set_text(GTK_ENTRY(entry), "");
+
+    for (url = cfg.url_history; url; url = g_list_next(url))
+        gtk_combo_box_append_text(GTK_COMBO_BOX(combo), (const gchar *) url->data);
+
+    g_signal_connect(entry, "activate",
+                     G_CALLBACK(util_add_url_callback),
+                     entry);
+    g_signal_connect(entry, "activate",
+                     G_CALLBACK(ok_func),
+                     entry);
+    g_signal_connect_swapped(entry, "activate",
+                             G_CALLBACK(gtk_widget_destroy),
+                             win);
+
+    bbox = gtk_hbutton_box_new();
+    gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
+    gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
+    gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
+
+    ok = gtk_button_new_from_stock(GTK_STOCK_OPEN);
+    g_signal_connect(ok, "clicked",
+             G_CALLBACK(util_add_url_callback), entry);
+    g_signal_connect(ok, "clicked",
+             G_CALLBACK(ok_func), entry);
+    g_signal_connect_swapped(ok, "clicked",
+                             G_CALLBACK(gtk_widget_destroy),
+                             win);
+    gtk_box_pack_start(GTK_BOX(bbox), ok, FALSE, FALSE, 0);
+
+    enqueue = gtk_button_new_from_stock(GTK_STOCK_ADD);
+    gtk_box_pack_start(GTK_BOX(bbox), enqueue, FALSE, FALSE, 0);
+
+    g_signal_connect(enqueue, "clicked",
+                     G_CALLBACK(util_add_url_callback),
+                     entry);
+    g_signal_connect(enqueue, "clicked",
+                     G_CALLBACK(enqueue_func),
+                     entry);
+    g_signal_connect_swapped(enqueue, "clicked",
+                             G_CALLBACK(gtk_widget_destroy),
+                             win);
+
+    cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
+    gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0);
+
+    g_signal_connect_swapped(cancel, "clicked",
+                             G_CALLBACK(gtk_widget_destroy),
+                             win);
+
+    gtk_widget_show_all(vbox);
+
+    return win;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audacious/ui_urlopener.h	Sat Jan 27 04:37:49 2007 -0800
@@ -0,0 +1,43 @@
+/*  Audacious - Cross-platform multimedia player
+ *  Copyright (C) 2005-2007  Audacious development team
+ *
+ *  Based on BMP:
+ *  Copyright (C) 2003-2004  BMP development team
+ *
+ *  Based on XMMS:
+ *  Copyright (C) 1998-2003  XMMS development team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; under version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __AUDACIOUS_UI_URLOPENER_H__
+#define __AUDACIOUS_UI_URLOPENER_H__
+
+#ifdef _AUDACIOUS_CORE
+# ifdef HAVE_CONFIG_H
+#  include "config.h"
+# endif
+#endif
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+GtkWidget *util_add_url_dialog_new(const gchar * caption, GCallback ok_func,
+                                   GCallback enqueue_func);
+
+G_END_DECLS
+
+#endif
--- a/src/audacious/util.c	Sat Jan 27 04:32:08 2007 -0800
+++ b/src/audacious/util.c	Sat Jan 27 04:37:49 2007 -0800
@@ -569,109 +569,6 @@
     *y = CLAMP(pos->y - 2, 0, MAX(0, screen_height - requisition.height));
 }
 
-#define URL_HISTORY_MAX_SIZE 30
-
-static void
-util_add_url_callback(GtkWidget * widget,
-                      GtkEntry * entry)
-{
-    const gchar *text;
-
-    text = gtk_entry_get_text(entry);
-    if (g_list_find_custom(cfg.url_history, text, (GCompareFunc) strcasecmp))
-        return;
-
-    cfg.url_history = g_list_prepend(cfg.url_history, g_strdup(text));
-
-    while (g_list_length(cfg.url_history) > URL_HISTORY_MAX_SIZE) {
-        GList *node = g_list_last(cfg.url_history);
-        g_free(node->data);
-        cfg.url_history = g_list_delete_link(cfg.url_history, node);
-    }
-}
-
-GtkWidget *
-util_add_url_dialog_new(const gchar * caption, GCallback ok_func,
-    GCallback enqueue_func)
-{
-    GtkWidget *win, *vbox, *bbox, *enqueue, *ok, *cancel, *combo, *entry, 
-          *label;
-    GList *url;
-
-    win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-    gtk_window_set_title(GTK_WINDOW(win), _("Add/Open URL Dialog"));
-    gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_DIALOG);
-    gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER);
-    gtk_window_set_default_size(GTK_WINDOW(win), 400, -1);
-    gtk_container_set_border_width(GTK_CONTAINER(win), 12);
-
-    vbox = gtk_vbox_new(FALSE, 10);
-    gtk_container_add(GTK_CONTAINER(win), vbox);
-
-    label = gtk_label_new(caption);
-    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
-
-    combo = gtk_combo_box_entry_new_text();
-    gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0);
-
-    entry = gtk_bin_get_child(GTK_BIN(combo));
-    gtk_window_set_focus(GTK_WINDOW(win), entry);
-    gtk_entry_set_text(GTK_ENTRY(entry), "");
-
-    for (url = cfg.url_history; url; url = g_list_next(url))
-        gtk_combo_box_append_text(GTK_COMBO_BOX(combo), (const gchar *) url->data);
-
-    g_signal_connect(entry, "activate",
-                     G_CALLBACK(util_add_url_callback),
-                     entry);
-    g_signal_connect(entry, "activate",
-                     G_CALLBACK(ok_func),
-                     entry);
-    g_signal_connect_swapped(entry, "activate",
-                             G_CALLBACK(gtk_widget_destroy),
-                             win);
-
-    bbox = gtk_hbutton_box_new();
-    gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
-    gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
-    gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
-
-    ok = gtk_button_new_from_stock(GTK_STOCK_OPEN);
-    g_signal_connect(ok, "clicked",
-             G_CALLBACK(util_add_url_callback), entry);
-    g_signal_connect(ok, "clicked",
-             G_CALLBACK(ok_func), entry);
-    g_signal_connect_swapped(ok, "clicked",
-                             G_CALLBACK(gtk_widget_destroy),
-                             win);
-    gtk_box_pack_start(GTK_BOX(bbox), ok, FALSE, FALSE, 0);
-
-    enqueue = gtk_button_new_from_stock(GTK_STOCK_ADD);
-    gtk_box_pack_start(GTK_BOX(bbox), enqueue, FALSE, FALSE, 0);
-
-    g_signal_connect(enqueue, "clicked",
-                     G_CALLBACK(util_add_url_callback),
-                     entry);
-    g_signal_connect(enqueue, "clicked",
-                     G_CALLBACK(enqueue_func),
-                     entry);
-    g_signal_connect_swapped(enqueue, "clicked",
-                             G_CALLBACK(gtk_widget_destroy),
-                             win);
-
-    cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
-    gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0);
-
-    g_signal_connect_swapped(cancel, "clicked",
-                             G_CALLBACK(gtk_widget_destroy),
-                             win);
-
-    gtk_widget_show_all(vbox);
-
-    return win;
-}
-
 GdkFont *
 util_font_load(const gchar * name)
 {
--- a/src/audacious/util.h	Sat Jan 27 04:32:08 2007 -0800
+++ b/src/audacious/util.h	Sat Jan 27 04:37:49 2007 -0800
@@ -57,8 +57,6 @@
 void glist_movedown(GList * list);
 void glist_moveup(GList * list);
 
-GtkWidget *util_add_url_dialog_new(const gchar * caption, GCallback ok_func,
-                                   GCallback enqueue_func);
 void util_menu_position(GtkMenu * menu, gint * x, gint * y,
                         gboolean * push_in, gpointer data);