[girl] Initial GTK+ 3 port of GNOME Internet Radio Locator
- From: ole <ole src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [girl] Initial GTK+ 3 port of GNOME Internet Radio Locator
- Date: Wed, 15 Mar 2017 22:41:47 +0000 (UTC)
commit 891f14aeeb3d30926d362f718faeb902faa6770e
Author: Ole Aamot <oka oka no>
Date: Wed Mar 15 23:40:48 2017 +0100
Initial GTK+ 3 port of GNOME Internet Radio Locator
src/GIRL.c | 146 +++++++++++++++++++++++++++++++++++++++++++++++-
src/GIRL.h | 19 ++-----
src/girl.c | 182 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 330 insertions(+), 17 deletions(-)
---
diff --git a/src/GIRL.c b/src/GIRL.c
index 58a18e3..a2b8530 100644
--- a/src/GIRL.c
+++ b/src/GIRL.c
@@ -1,21 +1,162 @@
#include <gtk/gtk.h>
+#include <gtk/gtkdialog.h>
#include <champlain/champlain.h>
#include <champlain-gtk/champlain-gtk.h>
#include <clutter-gtk/clutter-gtk.h>
+#include <glib/gstdio.h>
+#include <string.h>
static ChamplainView *champlain_view;
+GtkApplication *app;
+GtkWidget *search_selector;
+GtkWidget *window;
+
+static void
+new_station(GSimpleAction *simple, GVariant *parameter, gpointer user_data) {
+ g_print("New Internet Radio Station\n");
+ return;
+}
+
+static void
+search_station(GSimpleAction *simple, GVariant *parameter, gpointer user_data) {
+ g_print("Search Internet Radio Station\n");
+ return;
+}
+
+static void
+listen_station(GSimpleAction *simple, GVariant *parameter, gpointer user_data) {
+ g_print("Listen to Internet Radio Station\n");
+ return;
+}
+
+static void
+pause_station(GSimpleAction *simple, GVariant *parameter, gpointer user_data) {
+ g_print("Pause Internet Radio Station\n");
+ return;
+}
+
+static void
+prev_station(GSimpleAction *simple, GVariant *parameter, gpointer user_data) {
+ g_print("Previous Internet Radio Station\n");
+ return;
+}
+
+static void
+stations_all(GSimpleAction *simple, GVariant *parameter, gpointer user_data) {
+ g_print("79 Internet Radio Stations\n");
+ return;
+}
+
+static void
+next_station(GSimpleAction *simple, GVariant *parameter, gpointer user_data) {
+ g_print("Next Internet Radio Station\n");
+ return;
+}
+
+static void
+about_station(GSimpleAction *simple, GVariant *parameter, gpointer user_data) {
+ g_print("About Internet Radio Station\n");
+ return;
+}
+
+static void
+about_program(GSimpleAction *simple, GVariant *parameter, gpointer user_data) {
+ g_print("About Internet Radio Program\n");
+ return;
+}
+
+static void
+quit_program(GSimpleAction *simple, GVariant *parameter, gpointer user_data) {
+ g_application_quit(app);
+ return;
+}
static void
girl_window (GtkApplication *app,
gpointer user_data)
{
- GtkWidget *window, *widget;
+ GtkWidget *widget, *grid, *toolbar, *new, *search, *listen, *pause, *prev, *stations, *next, *station,
*program, *quit;
window = gtk_application_window_new (app);
widget = gtk_champlain_embed_new();
+ toolbar = gtk_toolbar_new();
+
+ new = gtk_tool_button_new(gtk_image_new_from_icon_name(NULL, GTK_ICON_SIZE_BUTTON), "New");
+ gtk_tool_item_set_is_important(GTK_TOOL_ITEM(new), TRUE);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM(new), 0);
+ gtk_widget_show (GTK_WIDGET(new));
+ gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(new), "New Station");
+ g_signal_connect(new, "clicked", G_CALLBACK (new_station), GTK_WINDOW (window));
+
+ search = gtk_tool_button_new(gtk_image_new_from_icon_name(NULL, GTK_ICON_SIZE_BUTTON), "Search");
+ gtk_tool_item_set_is_important(GTK_TOOL_ITEM(search), TRUE);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM(search), 1);
+ gtk_widget_show (GTK_WIDGET(search));
+ gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(search), "Search Internet Radio Station");
+ g_signal_connect(search, "clicked", G_CALLBACK (search_station), GTK_WINDOW (window));
+
+ listen = gtk_tool_button_new(gtk_image_new_from_icon_name(NULL, GTK_ICON_SIZE_BUTTON), "Listen");
+ gtk_tool_item_set_is_important(GTK_TOOL_ITEM(listen), TRUE);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM(listen), 2);
+ gtk_widget_show (GTK_WIDGET(listen));
+ gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(listen), "Listen Internet Radio Station");
+ g_signal_connect(listen, "clicked", G_CALLBACK (listen_station), GTK_WINDOW (window));
+
+ pause = gtk_tool_button_new(gtk_image_new_from_icon_name(NULL, GTK_ICON_SIZE_BUTTON), "Pause");
+ gtk_tool_item_set_is_important(GTK_TOOL_ITEM(pause), TRUE);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM(pause), 3);
+ gtk_widget_show (GTK_WIDGET(pause));
+ gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(pause), "Pause Internet Radio Station");
+ g_signal_connect(pause, "clicked", G_CALLBACK (pause_station), GTK_WINDOW (window));
+
+ prev = gtk_tool_button_new(gtk_image_new_from_icon_name(NULL, GTK_ICON_SIZE_BUTTON), "Prev");
+ gtk_tool_item_set_is_important(GTK_TOOL_ITEM(prev), TRUE);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM(prev), 4);
+ gtk_widget_show (GTK_WIDGET(prev));
+ gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(prev), "Prev Internet Radio Station");
+ g_signal_connect(prev, "clicked", G_CALLBACK (prev_station), GTK_WINDOW (window));
+
+ stations = gtk_tool_button_new(gtk_image_new_from_icon_name(NULL, GTK_ICON_SIZE_BUTTON), "Stations");
+ gtk_tool_item_set_is_important(GTK_TOOL_ITEM(stations), TRUE);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM(stations), 5);
+ gtk_widget_show (GTK_WIDGET(stations));
+ gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(stations), "Stations");
+ g_signal_connect(stations, "clicked", G_CALLBACK (stations_all), GTK_WINDOW (window));
+
+ next = gtk_tool_button_new(gtk_image_new_from_icon_name(NULL, GTK_ICON_SIZE_BUTTON), "Next");
+ gtk_tool_item_set_is_important(GTK_TOOL_ITEM(next), TRUE);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM(next), 6);
+ gtk_widget_show (GTK_WIDGET(next));
+ gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(next), "Next Internet Radio Station");
+ g_signal_connect(next, "clicked", G_CALLBACK (next_station), GTK_WINDOW (window));
+
+ station = gtk_tool_button_new(gtk_image_new_from_icon_name(NULL, GTK_ICON_SIZE_BUTTON), "About
Station");
+ gtk_tool_item_set_is_important(GTK_TOOL_ITEM(station), TRUE);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM(station), 7);
+ gtk_widget_show (GTK_WIDGET(station));
+ gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(station), "About Station");
+ g_signal_connect(station, "clicked", G_CALLBACK (about_station), GTK_WINDOW (window));
+
+ program = gtk_tool_button_new(gtk_image_new_from_icon_name(NULL, GTK_ICON_SIZE_BUTTON), "About
Program");
+ gtk_tool_item_set_is_important(GTK_TOOL_ITEM(program), TRUE);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM(program), 8);
+ gtk_widget_show (GTK_WIDGET(program));
+ gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(program), "About Program");
+ g_signal_connect(program, "clicked", G_CALLBACK (about_program), GTK_WINDOW (window));
+
+ quit = gtk_tool_button_new(gtk_image_new_from_icon_name(NULL, GTK_ICON_SIZE_BUTTON), "Exit");
+ gtk_tool_item_set_is_important(GTK_TOOL_ITEM(quit), TRUE);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM(quit), 9);
+ gtk_widget_show (GTK_WIDGET(quit));
+ gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(quit), "Exit Program");
+ g_signal_connect(quit, "clicked", G_CALLBACK (quit_program), GTK_WINDOW (window));
+
+ grid = gtk_grid_new();
+ gtk_grid_attach (GTK_GRID(grid), toolbar, 0, 0, 1, 1);
+ gtk_grid_attach (GTK_GRID(grid), widget, 0, 1, 1, 1);
champlain_view = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED(widget));
gtk_widget_set_size_request(widget, 1440, 720);
- gtk_container_add (GTK_CONTAINER(window), widget);
+ gtk_container_add (GTK_CONTAINER(window), GTK_WIDGET(grid));
g_signal_connect (window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_window_set_title (GTK_WINDOW(window), "GNOME Internet Radio Locator");
gtk_window_set_default_size (GTK_WINDOW(window), 1440, 720);
@@ -27,7 +168,6 @@ int
main (int argc,
char **argv)
{
- GtkApplication *app;
int status;
if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
diff --git a/src/GIRL.h b/src/GIRL.h
index c7748e8..49a8dfd 100644
--- a/src/GIRL.h
+++ b/src/GIRL.h
@@ -42,13 +42,11 @@ typedef enum {
GIRL_STREAM_RECORD = 0x0002
} GirlHelperType;
-#include <gnome.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include "girl-listener.h"
-#include "girl-program.h"
-#include "girl-runners.h"
-#include "girl-streams.h"
-#include "girl-station.h"
+#include "GIRL-LISTENER.h"
+#include "GIRL-PROGRAM.h"
+#include "GIRL-RUNNERS.h"
+#include "GIRL-STREAMS.h"
+#include "GIRL-STATION.h"
#if GIRL_DEBUG == 0
#define GIRL_DEBUG_MSG(x...) g_message(x)
@@ -64,12 +62,6 @@ typedef enum {
void show_error(gchar * msg);
void statusbar_send_msg(const char *a, ...);
-/* GnomeVFSFileSize get_size(GnomeVFSURI *uri); */
-
-/* GnomeVFSURI *xfer_channels(gchar *src, gchar *dest); */
-
-gchar *copy_to_mem(GnomeVFSURI * uri, GnomeVFSFileSize len);
-
void appbar_send_msg(const char *a, ...);
gint girl_archive_new(gchar *title, gchar *file, gchar *codec);
@@ -99,7 +91,6 @@ void about_program(GtkWidget *, gpointer user_data);
struct _GirlData {
GtkImage *pixmap;
- GnomeAppBar *appbar;
GtkProgressBar *progress;
GtkAboutDialog *window;
GtkStatusbar *statusbar;
diff --git a/src/girl.c b/src/girl.c
index 3686e5e..92eaac6 100644
--- a/src/girl.c
+++ b/src/girl.c
@@ -869,6 +869,186 @@ void about_streams(GtkWidget * a, gpointer user_data)
}
+GtkWidget *create_search_selector(void) {
+
+ GirlStationInfo *stationinfo, *localstation;
+ GtkWidget *search_selector, *content_area;
+ GtkWidget *align, *textentry;
+ GtkEntryCompletion *completion;
+ GtkListStore *model;
+ GtkTreeIter iter;
+
+ gchar *world_station_xml_filename, *local_station_xml_file;
+
+ /* int i = 0, search_selection = -1; */
+
+ GStatBuf stats;
+
+ memset(&stats, 0, sizeof(stats));
+
+ /* The Stations dialog */
+ search_selector = gtk_dialog_new_with_buttons(_("Search by location"), GTK_WINDOW(girl_app), 0, /*
flags */
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_ACCEPT,
+ NULL);
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (search_selector));
+ gtk_container_set_border_width
+ (GTK_CONTAINER(GTK_DIALOG(search_selector)->vbox), 6);
+
+ align = gtk_alignment_new(0.5, 0.5, 0, 0);
+ gtk_container_add(GTK_CONTAINER
+ (GTK_DIALOG(search_selector)->vbox), align);
+ gtk_container_set_border_width(GTK_CONTAINER(align), 6);
+ gtk_widget_show(align);
+
+ textentry = gtk_entry_new();
+ completion = gtk_entry_completion_new();
+ gtk_entry_completion_set_text_column(completion, STATION_NAME);
+ gtk_entry_completion_set_text_column(completion, STATION_LOCATION);
+ gtk_entry_set_completion(GTK_ENTRY(textentry), completion);
+ g_signal_connect(G_OBJECT(completion), "match-selected",
+ G_CALLBACK(on_search_matches), NULL);
+ model = gtk_list_store_new(11, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING);
+
+ world_station_xml_filename = g_strconcat(GIRL_DATADIR, "/girl.xml", NULL);
+ GIRL_DEBUG_MSG("world_station_xml_filename = %s\n",
+ world_station_xml_filename);
+
+ if (world_station_xml_filename == NULL) {
+ g_warning(("Failed to open %s. Please install it.\n"),
+ world_station_xml_filename);
+ }
+
+ local_station_xml_file =
+ g_strconcat(g_get_home_dir(), "/.girl/girl.xml", NULL);
+
+ if (!g_stat(local_station_xml_file, &stats)) {
+ localstation = girl_station_load_from_file(NULL, local_station_xml_file);
+ } else {
+ localstation = NULL;
+ }
+
+ if (localstation == NULL) {
+ g_warning(_("Failed to open %s.\n"), local_station_xml_file);
+ }
+
+/* g_free (local_station_xml_file); */
+
+ stationinfo =
+ girl_station_load_from_file(localstation,
+ world_station_xml_filename);
+
+ girl_stations = NULL;
+
+ while (stationinfo != NULL) {
+
+ gtk_list_store_append(model, &iter);
+ gtk_list_store_set(model,
+ &iter,
+ STATION_NAME,
+ stationinfo->name,
+ STATION_LOCATION,
+ stationinfo->location,
+ STATION_URI,
+ stationinfo->stream->uri,
+ STATION_DESCRIPTION,
+ stationinfo->description,
+ STATION_FREQUENCY,
+ stationinfo->frequency,
+ STATION_BAND,
+ stationinfo->band,
+ STATION_TYPE,
+ stationinfo->type,
+ STATION_RANK,
+ stationinfo->rank,
+ STATION_BITRATE,
+ stationinfo->bitrate,
+ STATION_SAMPLERATE,
+ stationinfo->samplerate,
+ STATION_ID,
+ stationinfo->id,
+ -1);
+
+ stationinfo = stationinfo->next;
+ }
+
+ gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(model));
+
+ gtk_widget_show(textentry);
+ gtk_container_add(GTK_CONTAINER(content_area), textentry);
+
+#if 0
+ /* label = */
+ /* g_strconcat(stationinfo->name, " (", */
+ /* stationinfo->location, ")", NULL); */
+ /* station_uri = g_strdup(stationinfo->stream->uri); */
+ /* station_name = g_strdup(stationinfo->name); */
+ /* station_location = g_strdup(stationinfo->location); */
+ /* station_band = g_strdup(stationinfo->band); */
+ /* station_description = g_strdup(stationinfo->description); */
+ /* station_website = g_strdup(stationinfo->uri); */
+
+ /* girl_stations = g_list_append(girl_stations,(GirlStationInfo *)stationinfo); */
+
+ if (label != NULL) {
+ /* item = gtk_menu_item_new_with_label(label); */
+ /* gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); */
+ g_signal_connect(G_OBJECT(item), "activate",
+ G_CALLBACK
+ (on_stations_selector_changed),
+ NULL);
+ g_object_set_data(G_OBJECT(item), "station_uri",
+ (gpointer) station_uri);
+ g_object_set_data(G_OBJECT(item), "station_name",
+ (gpointer) station_name);
+ g_object_set_data(G_OBJECT(item),
+ "station_location",
+ (gpointer) station_location);
+ g_object_set_data(G_OBJECT(item),
+ "station_band",
+ (gpointer) station_band);
+ g_object_set_data(G_OBJECT(item),
+ "station_description",
+ (gpointer) station_description);
+ g_object_set_data(G_OBJECT(item),
+ "station_website",
+ (gpointer) station_website);
+ gtk_widget_show(item);
+ g_free(label);
+
+ /* selection */
+#if 0 /* FIXME */
+ if (selected_station_uri != NULL &&
+ !strcmp(selected_station_uri, station_uri))
+ search_selection = i;
+#endif
+ } else {
+ g_free(station_uri);
+ g_free(station_name);
+ g_free(station_location);
+ g_free(station_band);
+ g_free(station_description);
+ }
+ i++;
+ }
+
+ /* drop_down = gtk_option_menu_new(); */
+ /* gtk_widget_show(drop_down); */
+ /* gtk_option_menu_set_menu(GTK_OPTION_MENU(drop_down), menu); */
+ /* gtk_container_add(GTK_CONTAINER(align), drop_down); */
+
+ /* if (selection != -1) */
+ /* gtk_option_menu_set_history(GTK_OPTION_MENU(drop_down), selection); */
+#endif
+ g_signal_connect(G_OBJECT(search_selector), "response",
+ G_CALLBACK(gtk_widget_hide),
+ (gpointer) search_selector);
+ g_signal_connect(G_OBJECT(search_selector), "delete-event",
+ G_CALLBACK(gtk_widget_hide),
+ (gpointer) search_selector);
+
+ return search_selector;
+}
void on_search_button_clicked(GtkWidget *a, gpointer user_data)
{
@@ -880,6 +1060,8 @@ void on_search_button_clicked(GtkWidget *a, gpointer user_data)
appbar_send_msg(_("Search radio station by location"));
}
+
+
void on_listen_button_clicked(GtkWidget *a, gpointer user_data)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]