/* * This file part of gsopcast - A gtk front-end of p2p tv sopcast. * http://lianwei3.googlepages.com/home2 * Copyright (C) 2006 Wei Lian * * 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; either version 2 of the License, or * (at your option) any later version. * * 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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H #include #endif #include #include "header.h" #include "sound.h" #include "fork.h" #include "iosignal.h" #include "loadsave.h" #include "callbacks.h" #include "iochannel.h" #include "unique.h" GtkWidget *window1; GtkWidget *button_channel; GtkWidget *button_expand; GtkWidget *label_player; GtkWidget *label_record; GtkWidget *entry_player; GtkWidget *entry_status; GtkWidget *entry_url; GtkWidget *entry_url_header; GtkWidget *entry_record_dir; //xihels@gmail.com/// GtkWidget *entry_inport; GtkWidget *entry_outport; // xihels@gmail.com// extern int stdout_pipe[2]; extern int stdin_pipe[2]; int signal_pipe[2]; extern pid_t pid_sop; extern pid_t pid_player; extern pid_t pid_channel; extern char *title; extern int title_len; GtkComboBoxEntry *combo_box_entry; extern GList *items_title; extern GList *items_url; GtkWidget *entry_search; GtkTreeView *tree_channel; GtkObject *adj_sound; Sound *sound; GtkWidget *notebook1; // timeout in minutes, really need a options struct/object to pass around. unsigned int channel_update_timeout = 60; //----------------------------------------------------- static GtkTreeModel *create_model() { GtkTreeStore *store; store = gtk_tree_store_new(N_COLUMNS, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); return GTK_TREE_MODEL(store); } //----------------------------------------------------- void cell_data_func_card(GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * model, GtkTreeIter * iter, gpointer user_data) { int card; gchar buf[16]; gtk_tree_model_get(model, iter, CARD_COLUMN, &card, -1); if (card > 0) ///group { g_snprintf(buf, sizeof(buf), "%u", card); } else ///channel { g_snprintf(buf, sizeof(buf), " "); } g_object_set(renderer, "text", buf, NULL); } //----------------------------------------------------- void cell_data_func_name(GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * model, GtkTreeIter * iter, gpointer user_data) { int card; gtk_tree_model_get(model, iter, CARD_COLUMN, &card, -1); if (card == -1) ///marked by search { g_object_set(renderer, "background", "yellow", NULL); //grey90", NULL); //goldenrod4", NULL); } else { g_object_set(renderer, "background-set", FALSE, NULL); } } //----------------------------------------------------- static void add_columns(GtkTreeView * tree) { GtkTreeViewColumn *column; GtkCellRenderer *renderer; //Num /* renderer = gtk_cell_renderer_text_new (); g_object_set (G_OBJECT (renderer), "foreground", "blue", NULL); column = gtk_tree_view_column_new_with_attributes ("num", renderer, "text", NUM_COLUMN, NULL); gtk_tree_view_column_set_sort_column_id (column, NUM_COLUMN); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);*/ //Cardinality renderer = gtk_cell_renderer_text_new(); g_object_set(G_OBJECT(renderer), "foreground", "blue", NULL); column = gtk_tree_view_column_new_with_attributes("#", renderer, NULL); gtk_tree_view_column_set_cell_data_func(column, renderer, cell_data_func_card, NULL, NULL); gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_column_set_sort_column_id(column, CARD_COLUMN); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); //Name renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("name"), renderer, "text", NAME_COLUMN, NULL); gtk_tree_view_column_set_cell_data_func(column, renderer, cell_data_func_name, NULL, NULL); gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_column_set_sort_column_id(column, NAME_COLUMN); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); //user renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("user"), renderer, "text", USER_COLUMN, NULL); gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_column_set_sort_column_id(column, USER_COLUMN); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); //visit renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("visit"), renderer, "text", VISIT_COLUMN, NULL); gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_column_set_sort_column_id(column, VISIT_COLUMN); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); //Kbps renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("kbps"), renderer, "text", KBPS_COLUMN, NULL); gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_column_set_sort_column_id(column, KBPS_COLUMN); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); //qs renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("qs"), renderer, "text", QS_COLUMN, NULL); gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_column_set_sort_column_id(column, QS_COLUMN); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); //qc renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("qc"), renderer, "text", QC_COLUMN, NULL); gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_column_set_sort_column_id(column, QC_COLUMN); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); //start from renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("start__from"), renderer, "text", START_COLUMN, NULL); gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_column_set_sort_column_id(column, START_COLUMN); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); //stream type renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("type"), renderer, "text", STREAM_COLUMN, NULL); gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_column_set_sort_column_id(column, STREAM_COLUMN); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); //Status renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("status"), renderer, "text", STATUS_COLUMN, NULL); gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_column_set_sort_column_id(column, STATUS_COLUMN); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); //URL renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("sop__address"), renderer, "text", URL_COLUMN, NULL); gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_column_set_sort_column_id(column, URL_COLUMN); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); } //----------------------------------------------------- void change_notebook_tab(gboolean right) { int num_pages, page_num; num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook1)); page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook1)); if (right) { if (page_num < num_pages - 1) { page_num++; } else { // Wrap around page_num = 0; } } else { if (page_num > 0) { page_num--; } else { // Wrap around page_num = num_pages - 1; } } gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook1), page_num); } GHashTable *option_map; //-------------------------------------------------- /* Parse the command line options. */ GHashTable* parse_command_line(int *argc, char*** argv){ GHashTable *option_map = NULL; gboolean remote = FALSE; GOptionEntry entries[] = { {"remote", 'r', 0, G_OPTION_ARG_NONE, &remote, _("Open in an existing instance"), NULL}, {NULL}, }; GError *error = NULL; GOptionContext *context; context = g_option_context_new("gsopcast"); g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE); g_option_context_add_group(context, gtk_get_option_group(TRUE)); g_option_context_set_ignore_unknown_options(context, TRUE); g_option_context_parse(context, argc, argv, &error); if (error != NULL){ g_warning("Bad Command line option."); exit(1); } option_map = g_hash_table_new(g_str_hash, g_str_equal); g_hash_table_insert(option_map, (gpointer)"remote", (gpointer)remote); return option_map; } //----------------------------------------------------- int main(int argc, char *argv[]) { // GtkWidget *window1; GtkWidget *hbox_desc; GtkWidget *scrolledwindow_desc; GtkWidget *textview_desc; GtkWidget *vbox; GtkWidget *scrolledwindow1; // GtkWidget *tree_channel; GtkWidget *label; // GtkWidget *label_player; // GtkWidget *label_record; GtkWidget *hbox; GtkWidget *button; GtkWidget *button_player; // GtkWidget *button_channel; GtkWidget *button_stop; GtkWidget *button_exit; GtkWidget *button_record; GtkWidget *hscale_sound; // GtkWidget *entry_status; // GtkWidget *entry_player; // GtkWidget *entry_url_header; GtkWidget *button_save; bindtextdomain (GETTEXT_PACKAGE, GSOPCAST_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); gtk_init(&argc, &argv); option_map = parse_command_line(&argc, &argv); if (g_hash_table_lookup(option_map, (gconstpointer)"remote")) { if (is_running()){ if (argc == 2) { unique_paste_uri(argv[1]); } return 0; } } window1 = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_realize(window1); unique_set_text("NONE", FALSE); setup_unique(); // gtk_widget_set_usize (GTK_WIDGET (window1), 450, 350); gtk_window_set_title(GTK_WINDOW(window1), "gsopcast - "VERSION); notebook1 = gtk_notebook_new(); gtk_container_add(GTK_CONTAINER(window1), notebook1); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(notebook1), vbox); //////search and toggle expand/collapse hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); button_channel = gtk_toggle_button_new_with_label(_("Channel")); gtk_box_pack_start(GTK_BOX(hbox), button_channel, FALSE, FALSE, 0); gtk_button_set_relief(GTK_BUTTON(button_channel), GTK_RELIEF_NONE); gtk_button_set_focus_on_click(GTK_BUTTON(button_channel), FALSE); g_signal_connect(G_OBJECT(button_channel), "toggled", G_CALLBACK(on_button_channel_toggled), NULL); entry_search = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), entry_search, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(entry_search), "activate", G_CALLBACK(on_entry_search_activated), NULL); button = gtk_button_new_with_label(_("Search")); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_button_set_focus_on_click(GTK_BUTTON(button), FALSE); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(on_button_search_clicked), NULL); button_expand = gtk_button_new_with_label(_("Expand")); gtk_box_pack_start(GTK_BOX(hbox), button_expand, FALSE, FALSE, 0); gtk_button_set_relief(GTK_BUTTON(button_expand), GTK_RELIEF_NONE); gtk_button_set_focus_on_click(GTK_BUTTON(button_expand), FALSE); g_signal_connect(G_OBJECT(button_expand), "clicked", G_CALLBACK(on_button_expand_clicked), NULL); ///// hbox_desc = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox_desc, TRUE, TRUE, 0); scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL); gtk_box_pack_start(GTK_BOX(hbox_desc), scrolledwindow1, TRUE, TRUE, 0); // gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), // GTK_SHADOW_IN); ////////////tree view tree_channel = GTK_TREE_VIEW(gtk_tree_view_new()); GtkTreeModel *model = create_model(); gtk_tree_view_set_model(tree_channel, model); g_object_unref(model); // gtk_tree_view_set_rules_hint (tree_channel, TRUE); add_columns(tree_channel); gtk_container_add(GTK_CONTAINER(scrolledwindow1), GTK_WIDGET(tree_channel)); g_signal_connect(G_OBJECT(tree_channel), "row-activated", G_CALLBACK(on_treeview1_row_activated), NULL); /* gboolean on_treeview1_row_selected (); g_signal_connect (G_OBJECT (tree_channel), "cursor-changed", G_CALLBACK (on_treeview1_row_selected), NULL);*/ // Setup description pan scrolledwindow_desc = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow_desc), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); textview_desc = gtk_text_view_new(); gtk_widget_set_size_request(textview_desc, 256, -1); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview_desc), GTK_WRAP_WORD_CHAR); gtk_text_view_set_editable(GTK_TEXT_VIEW(textview_desc), FALSE); gtk_container_add(GTK_CONTAINER(scrolledwindow_desc), GTK_WIDGET(textview_desc)); gtk_box_pack_start(GTK_BOX(hbox_desc), scrolledwindow_desc, FALSE, TRUE, 0); g_signal_connect (G_OBJECT (tree_channel), "cursor-changed", G_CALLBACK (on_treeview1_row_selected), textview_desc); ///////////combo_box_entry GtkListStore *combo_list; hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); items_title = NULL; items_url = NULL; combo_list = gtk_list_store_new(1, G_TYPE_STRING); combo_box_entry = GTK_COMBO_BOX_ENTRY( gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(combo_list), 0)); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(combo_box_entry), TRUE, TRUE, 0); g_signal_connect(G_OBJECT (GTK_BIN(combo_box_entry)->child), "activate", G_CALLBACK (on_button_sopcast_clicked), NULL); button = gtk_button_new_with_label(_("Launch")); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_button_set_focus_on_click(GTK_BUTTON(button), FALSE); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(on_button_sopcast_clicked), NULL); ////////////buttons hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); button_player = gtk_button_new(); label_player = gtk_label_new(_("Play")); gtk_container_add(GTK_CONTAINER(button_player), label_player); gtk_box_pack_start(GTK_BOX(hbox), button_player, FALSE, FALSE, 0); gtk_button_set_relief(GTK_BUTTON(button_player), GTK_RELIEF_NONE); gtk_button_set_focus_on_click(GTK_BUTTON(button_player), FALSE); g_signal_connect(G_OBJECT(button_player), "clicked", G_CALLBACK(on_button_player_clicked), NULL); button_stop = gtk_button_new_with_label(_("Stop")); gtk_box_pack_start(GTK_BOX(hbox), button_stop, FALSE, FALSE, 0); gtk_button_set_relief(GTK_BUTTON(button_stop), GTK_RELIEF_NONE); gtk_button_set_focus_on_click(GTK_BUTTON(button_stop), FALSE); g_signal_connect(G_OBJECT(button_stop), "clicked", G_CALLBACK(on_button_stop_clicked), NULL); button_exit = gtk_button_new_with_label(_("Exit")); gtk_box_pack_start(GTK_BOX(hbox), button_exit, FALSE, FALSE, 0); gtk_button_set_relief(GTK_BUTTON(button_exit), GTK_RELIEF_NONE); gtk_button_set_focus_on_click(GTK_BUTTON(button_exit), FALSE); g_signal_connect(G_OBJECT(button_exit), "clicked", G_CALLBACK(on_button_exit_clicked), NULL); ///////////open mixer try { sound = NULL; sound = new Sound(); adj_sound = gtk_adjustment_new(sound->volume(), 0, 100, 5, 0, 0); g_signal_connect(G_OBJECT(adj_sound), "value_changed", G_CALLBACK(on_adj_sound_change_value), NULL); hscale_sound = gtk_hscale_new(GTK_ADJUSTMENT(adj_sound)); gtk_box_pack_start(GTK_BOX(hbox), hscale_sound, TRUE, TRUE, 0); gtk_scale_set_digits(GTK_SCALE(hscale_sound), 0); GTK_WIDGET_UNSET_FLAGS(hscale_sound, GTK_CAN_FOCUS); ////sound timer g_timeout_add(1000, sound_timer, NULL); }catch(SoundError *ex) { g_warning("Failed to start the sound system. Cannot adjust volume."); } button_record = gtk_button_new(); label_record = gtk_label_new(_("Record")); gtk_container_add(GTK_CONTAINER(button_record), label_record); gtk_box_pack_start(GTK_BOX(hbox), button_record, FALSE, FALSE, 0); gtk_button_set_relief(GTK_BUTTON(button_record), GTK_RELIEF_NONE); gtk_button_set_focus_on_click(GTK_BUTTON(button_record), FALSE); g_signal_connect(G_OBJECT(button_record), "clicked", G_CALLBACK(on_button_record_clicked), NULL); entry_status = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(vbox), entry_status, FALSE, FALSE, 0); // gtk_entry_set_editable (GTK_ENTRY (entry_status), FALSE); // gtk_widget_set_sensitive (entry_status, FALSE); GTK_WIDGET_UNSET_FLAGS(entry_status, GTK_CAN_FOCUS); label = gtk_label_new(_("sopcast")); g_object_set(G_OBJECT(label), "can-focus", FALSE, NULL); gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook1), gtk_notebook_get_nth_page(GTK_NOTEBOOK (notebook1), 0), label); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(notebook1), vbox); //// label = gtk_label_new(_("Configuration")); gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, FALSE, 0); //// hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new(_(" Player: ")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); entry_player = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), entry_player, TRUE, TRUE, 0); //// hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new(_(" Channels url: ")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); entry_url = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), entry_url, TRUE, TRUE, 0); //// hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new(_(" Channels url header: ")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); entry_url_header = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), entry_url_header, TRUE, TRUE, 0); //// hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new(_(" Record directory: ")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); entry_record_dir = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), entry_record_dir, TRUE, TRUE, 0); /// hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); // xihels@gmail.com////////////////////////////// label = gtk_label_new(_(" Inport: ")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); entry_inport = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), entry_inport, TRUE, TRUE, 0); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new(_(" Outport: ")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); entry_outport = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), entry_outport, TRUE, TRUE, 0); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, FALSE, 0); /////////////////////////////////////////////////////// button_save = gtk_button_new_with_label(_(" Save ")); gtk_box_pack_start(GTK_BOX(hbox), button_save, TRUE, FALSE, 0); g_signal_connect(G_OBJECT(button_save), "clicked", G_CALLBACK(on_button_save_clicked), NULL); /// label = gtk_label_new(_("config")); g_object_set(G_OBJECT(label), "can-focus", FALSE, NULL); gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook1), gtk_notebook_get_nth_page(GTK_NOTEBOOK (notebook1), 1), label); gchar *about_str; about_str = g_strdup_printf(_("gsopcast -- a gtk front-end to p2p TV sopcast\n\n(c)2005-2008 Wei Lian. All rights reserved.\n\nVersion %s\n\nhttp://lianwei3.googlepages.com/home2\n\nIts prototype is contributed to pinkme005 and zlbruce\n\nMany thanks to jazzi for his persistent support"), VERSION); label = gtk_label_new(about_str); g_free(about_str); gtk_container_add(GTK_CONTAINER(notebook1), label); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); label = gtk_label_new(_("about")); g_object_set(G_OBJECT(label), "can-focus", FALSE, NULL); gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook1), gtk_notebook_get_nth_page(GTK_NOTEBOOK (notebook1), 2), label); g_signal_connect(G_OBJECT(window1), "destroy", G_CALLBACK(on_window1_destroy), NULL); g_signal_connect(G_OBJECT(window1), "key_press_event", G_CALLBACK(vKeyPressReleaseCallback), NULL); // g_signal_connect (G_OBJECT (window1), "key_release_event", // G_CALLBACK (vKeyPressReleaseCallback), NULL); ////////////////////////////////////////////////// ///setup stdin_pipe for player if (pipe(stdin_pipe)) { perror("stdin pipe"); exit(1); } fcntl(stdin_pipe[1], F_SETFL, fcntl(stdin_pipe[1], F_GETFL) | O_NONBLOCK); ///setup stdout_pipe for channel if (pipe(stdout_pipe)) { perror("stdout pipe"); exit(1); } fcntl(stdout_pipe[1], F_SETFL, fcntl(stdout_pipe[1], F_GETFL) | O_NONBLOCK); ////iochannel for stdout_pipe Channel iostdout; create_iochannel(iostdout, stdout_pipe[0], handle_stdout_pipe); ///setup signal_pipe if (pipe(signal_pipe)) { perror("signal pipe"); exit(1); } fcntl(signal_pipe[1], F_SETFL, fcntl(signal_pipe[1], F_GETFL) | O_NONBLOCK); ////signal signal(SIGCHLD, pipe_signals); ////iochannel for signal_pipe Channel iosignal; create_iochannel(iosignal, signal_pipe[0], handle_io_pipe); ///////////assign initial value pid_channel = -2; title = NULL; title_len = 0; pid_player = -2; pid_sop = -2; ///////////load config load_config(); //////////////////load tree state load_tree_state(); //////////////////set time seed srand((unsigned) time(NULL)); //////set locale //setlocale(LC_CTYPE, "zh_CN.GBK"); ////Periodically update channel list g_timeout_add(1000*60*channel_update_timeout, on_channel_update, NULL); ///////////////////main loop gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_channel), TRUE); gtk_widget_show_all(window1); gtk_widget_grab_focus(entry_search); ////////////////Start connection if we see a command line uri. if (argc == 2){ GtkEntry *entry; entry = GTK_ENTRY(GTK_BIN(combo_box_entry)->child); gtk_entry_set_text(entry, argv[1]); on_button_sopcast_clicked(); } gtk_main(); ////////////close aumix if (sound) delete sound; if (title) free(title); return 0; }