mp3splt-gtk
|
00001 /********************************************************** 00002 * 00003 * mp3splt-gtk -- utility based on mp3splt, 00004 * for mp3/ogg splitting without decoding 00005 * 00006 * Copyright: (C) 2005-2012 Alexandru Munteanu 00007 * Contact: io_fx@yahoo.fr 00008 * 00009 * http://mp3splt.sourceforge.net/ 00010 * 00011 *********************************************************/ 00012 00013 /********************************************************** 00014 * 00015 * This program is free software; you can redistribute it and/or 00016 * modify it under the terms of the GNU General Public License 00017 * as published by the Free Software Foundation; either version 2 00018 * of the License, or (at your option) any later version. 00019 * 00020 * This program is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * You should have received a copy of the GNU General Public License 00026 * along with this program; if not, write to the Free Software 00027 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00028 * USA. 00029 * 00030 *********************************************************/ 00031 00032 /*!******************************************************** 00033 * \file 00034 * The main window 00035 * 00036 * main file that initialises the menubar, the toolbar, 00037 * the tabs, about window, status error messages 00038 * 00039 *********************************************************/ 00040 00041 //we include the "config.h" file from the config options 00042 #ifdef HAVE_CONFIG_H 00043 #include "config.h" 00044 #else 00045 #define VERSION "0.7.2" 00046 #define PACKAGE_NAME "mp3splt-gtk" 00047 #endif 00048 00049 #include <string.h> 00050 #include "export.h" 00051 00052 #include <gtk/gtk.h> 00053 #include <glib/gi18n.h> 00054 #include <libmp3splt/mp3splt.h> 00055 #include <gdk/gdkkeysyms.h> 00056 00057 #ifdef __WIN32__ 00058 #include <windows.h> 00059 #include <shlwapi.h> 00060 #endif 00061 00062 00063 #include "util.h" 00064 #include "main_win.h" 00065 #include "mp3splt-gtk.h" 00066 #include "tree_tab.h" 00067 #include "split_files.h" 00068 #include "utilities.h" 00069 #include "preferences_tab.h" 00070 #include "freedb_tab.h" 00071 #include "special_split.h" 00072 #include "utilities.h" 00073 #include "player_tab.h" 00074 #include "player.h" 00075 #include "messages.h" 00076 #include "import.h" 00077 #include "preferences_manager.h" 00078 #include "player_tab.h" 00079 00080 #include "ui_manager.h" 00081 00082 //main window 00083 GtkWidget *window = NULL; 00084 GtkAccelGroup *window_accel_group = NULL; 00085 00086 //status bar 00087 GtkWidget *status_bar; 00088 00089 //if we are on the preferences tab, then TRUE 00090 gint preferences_tab = FALSE; 00091 00092 //player box 00093 GtkWidget *player_box; 00094 00095 //the split freedb button 00096 GtkWidget *split_freedb_button; 00097 00098 //new window for the progress bar 00099 GtkWidget *percent_progress_bar; 00100 00101 //filename and path for the file to split 00102 gchar *filename_to_split; 00103 gchar *filename_path_of_split; 00104 00105 //if we are currently splitting 00106 gint we_are_splitting = FALSE; 00107 gint we_quit_main_program = FALSE; 00108 00109 GtkWidget *player_vbox = NULL; 00110 00111 //stop button to cancel the split 00112 GtkWidget *cancel_button = NULL; 00113 00114 extern GtkWidget *mess_history_dialog; 00115 00116 extern GtkWidget *da; 00117 extern GtkWidget *progress_bar; 00118 00119 extern GArray *splitpoints; 00120 extern gint selected_id; 00121 extern splt_state *the_state; 00122 extern splt_freedb_results *search_results; 00123 extern GList *player_pref_list; 00124 extern GList *text_options_list; 00125 extern gchar **split_files; 00126 extern gint max_split_files; 00127 extern gint selected_player; 00128 extern silence_wave *silence_points; 00129 extern gint number_of_silence_points; 00130 00131 extern ui_state *ui; 00132 00133 GtkWidget *playlist_box = NULL; 00134 00135 //close the window and exit button function 00136 void quit(GtkWidget *widget, gpointer data) 00137 { 00138 save_preferences(NULL, NULL); 00139 00140 if (we_are_splitting) 00141 { 00142 gint err = SPLT_OK; 00143 mp3splt_stop_split(the_state,&err); 00144 print_status_bar_confirmation(err); 00145 00146 we_quit_main_program = TRUE; 00147 put_status_message(_(" info: stopping the split process before exiting")); 00148 } 00149 00150 //quit the player: currently closes gstreamer 00151 if (player_is_running()) 00152 { 00153 player_quit(); 00154 } 00155 00156 g_list_free(player_pref_list); 00157 g_list_free(text_options_list); 00158 g_array_free(splitpoints, TRUE); 00159 00160 if (silence_points) 00161 { 00162 g_free(silence_points); 00163 silence_points = NULL; 00164 number_of_silence_points = 0; 00165 } 00166 00167 gtk_main_quit(); 00168 } 00169 00170 void main_window_drag_data_received(GtkWidget *window, 00171 GdkDragContext *drag_context, gint x, gint y, GtkSelectionData *data, guint 00172 info, guint time, gpointer user_data) 00173 { 00174 const gchar *received_data = (gchar *) gtk_selection_data_get_text(data); 00175 00176 if (received_data != NULL) 00177 { 00178 gchar **drop_filenames = NULL; 00179 drop_filenames = g_strsplit(received_data, "\n", 0); 00180 00181 gint current_index = 0; 00182 gchar *current_filename = drop_filenames[current_index]; 00183 while (current_filename != NULL) 00184 { 00185 gchar *filename = NULL; 00186 if (strstr(current_filename, "file:") == current_filename) 00187 { 00188 filename = g_filename_from_uri(current_filename, NULL, NULL); 00189 } 00190 else 00191 { 00192 gint fname_malloc_size = strlen(current_filename) + 1; 00193 filename = g_malloc(sizeof(gchar) * fname_malloc_size); 00194 g_snprintf(filename, fname_malloc_size, "%s", current_filename); 00195 } 00196 00197 remove_end_slash_n_r_from_filename(filename); 00198 00199 if (is_filee(filename)) 00200 { 00201 handle_import(filename); 00202 } 00203 00204 if (filename) 00205 { 00206 g_free(filename); 00207 filename = NULL; 00208 } 00209 00210 g_free(current_filename); 00211 current_index++; 00212 current_filename = drop_filenames[current_index]; 00213 } 00214 00215 if (drop_filenames) 00216 { 00217 g_free(drop_filenames); 00218 drop_filenames = NULL; 00219 } 00220 } 00221 } 00222 00223 gboolean configure_window_callback(GtkWindow *window, GdkEvent *event, gpointer data) 00224 { 00225 ui_state *ui = (ui_state *)data; 00226 00227 ui_set_main_win_position(ui, event->configure.x, event->configure.y); 00228 ui_set_main_win_size(ui, event->configure.width, event->configure.height); 00229 00230 return FALSE; 00231 } 00232 00233 void initialize_window() 00234 { 00235 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 00236 00237 g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(configure_window_callback), ui); 00238 00239 window_accel_group = gtk_accel_group_new(); 00240 gtk_window_add_accel_group(GTK_WINDOW(window), window_accel_group); 00241 00242 gtk_window_set_title(GTK_WINDOW(window), PACKAGE_NAME" "VERSION); 00243 gtk_container_set_border_width (GTK_CONTAINER (window), 0); 00244 00245 g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(quit), NULL); 00246 g_signal_connect(G_OBJECT(window), "drag-data-received", 00247 G_CALLBACK(main_window_drag_data_received), NULL); 00248 gtk_drag_dest_set(window, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, 00249 drop_types, 3, GDK_ACTION_COPY | GDK_ACTION_MOVE); 00250 00251 GString *Imagefile = g_string_new(""); 00252 build_path(Imagefile, PIXMAP_PATH, "mp3splt-gtk_ico"ICON_EXT); 00253 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(Imagefile->str, NULL); 00254 gtk_window_set_default_icon(pixbuf); 00255 g_string_free(Imagefile, TRUE); 00256 } 00257 00258 void activate_url(GtkAboutDialog *about, const gchar *link, gpointer data) 00259 { 00260 #ifdef __WIN32__ 00261 char default_browser[512] = { '\0' }; 00262 DWORD dwType, dwSize = sizeof(default_browser) - 1; 00263 00264 SHGetValue(HKEY_CURRENT_USER, 00265 TEXT("Software\\Clients\\StartMenuInternet"), 00266 TEXT(""), 00267 &dwType, 00268 default_browser, 00269 &dwSize); 00270 00271 if (default_browser[0] != '\0') 00272 { 00273 SHGetValue(HKEY_LOCAL_MACHINE, 00274 TEXT("SOFTWARE\\Clients\\StartMenuInternet"), 00275 TEXT(""), 00276 &dwType, 00277 default_browser, 00278 &dwSize); 00279 } 00280 00281 if (default_browser[0] != '\0') 00282 { 00283 char browser_exe[2048] = { '\0' }; 00284 dwSize = sizeof(browser_exe) - 1; 00285 00286 char browser_exe_registry[1024] = { '\0' }; 00287 snprintf(browser_exe_registry, 1024, 00288 "SOFTWARE\\Clients\\StartMenuInternet\\%s\\shell\\open\\command\\", 00289 default_browser); 00290 00291 SHGetValue(HKEY_LOCAL_MACHINE, 00292 TEXT(browser_exe_registry), TEXT(""), 00293 &dwType, browser_exe, &dwSize); 00294 00295 if (browser_exe[0] != '\0') 00296 { 00297 gint browser_command_size = strlen(browser_exe) + strlen(link) + 2; 00298 char *browser_command = g_malloc(sizeof(char) * browser_command_size); 00299 if (browser_command) 00300 { 00301 snprintf(browser_command, browser_command_size, "%s %s", 00302 browser_exe, link); 00303 00304 STARTUPINFO si; 00305 PROCESS_INFORMATION pinf; 00306 ZeroMemory(&si, sizeof(si)); 00307 si.cb = sizeof(si); 00308 ZeroMemory(&pinf, sizeof(pinf)); 00309 00310 if (! CreateProcess(NULL, browser_command, 00311 NULL, NULL, FALSE, 0, NULL, NULL, &si, &pinf)) 00312 { 00313 put_status_message(_("Error launching external command")); 00314 } 00315 00316 CloseHandle(pinf.hProcess); 00317 CloseHandle(pinf.hThread); 00318 00319 g_free(browser_command); 00320 browser_command = NULL; 00321 } 00322 } 00323 } 00324 #endif 00325 } 00326 00327 void about_window(GtkWidget *widget, gpointer *data) 00328 { 00329 GtkWidget *dialog = gtk_about_dialog_new(); 00330 00331 GString *Imagefile = g_string_new(""); 00332 build_path(Imagefile, PIXMAP_PATH, "mp3splt-gtk.png"); 00333 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(Imagefile->str, NULL); 00334 gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dialog), pixbuf); 00335 g_string_free(Imagefile, TRUE); 00336 00337 gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(dialog), (gchar *)PACKAGE_NAME); 00338 gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog), VERSION); 00339 gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(dialog), 00340 PACKAGE_NAME" : Copyright © 2005-2011 Alexandru" 00341 " Munteanu \n mp3splt : Copyright © 2002-2005 Matteo Trotta"); 00342 00343 gchar *b1 = NULL; 00344 gchar b3[100] = { '\0' }; 00345 b1 = (gchar *)_("using"); 00346 gchar library_version[20] = { '\0' }; 00347 mp3splt_get_version(library_version); 00348 g_snprintf(b3, 100, "-%s-\n%s libmp3splt %s", 00349 _("release of "MP3SPLT_GTK_DATE), b1, library_version); 00350 00351 gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(dialog), b3); 00352 00353 gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(dialog), 00354 "\n" 00355 "This program is free software; you can " 00356 "redistribute it and/or \n" 00357 "modify it under the terms of the GNU General Public License\n" 00358 "as published by the Free Software " 00359 "Foundation; either version 2\n" 00360 "of the License, or (at your option) " 00361 "any later version.\n\n" 00362 "This program is distributed in the " 00363 "hope that it will be useful,\n" 00364 "but WITHOUT ANY WARRANTY; without even " 00365 "the implied warranty of\n" 00366 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" 00367 "GNU General Public License for more details.\n\n" 00368 "You should have received a copy of the GNU General Public License\n" 00369 "along with this program; if not, write " 00370 "to the Free Software\n" 00371 "Foundation, Inc., 59 Temple Place -" 00372 "Suite 330, Boston, MA 02111-1307, " 00373 "USA."); 00374 00375 g_signal_connect(G_OBJECT(dialog), "activate-link", G_CALLBACK(activate_url), NULL); 00376 00377 gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(dialog), 00378 "http://mp3splt.sourceforge.net"); 00379 gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(dialog), 00380 "http://mp3splt.sourceforge.net"); 00381 00382 gtk_about_dialog_set_translator_credits(GTK_ABOUT_DIALOG(dialog), 00383 "Mario Blättermann <mariobl@gnome.org>"); 00384 00385 gtk_dialog_run(GTK_DIALOG(dialog)); 00386 gtk_widget_destroy(dialog); 00387 } 00388 00393 void remove_status_message() 00394 { 00395 guint status_id = 00396 gtk_statusbar_get_context_id(GTK_STATUSBAR(status_bar), "mess"); 00397 gtk_statusbar_pop(GTK_STATUSBAR(status_bar), status_id); 00398 } 00399 00407 void put_status_message(const gchar *text) 00408 { 00409 put_status_message_with_type(text, SPLT_MESSAGE_INFO); 00410 } 00411 00421 void put_status_message_with_type(const gchar *text, splt_message_type mess_type) 00422 { 00423 if (mess_type == SPLT_MESSAGE_INFO) 00424 { 00425 guint status_id = 00426 gtk_statusbar_get_context_id(GTK_STATUSBAR(status_bar), "mess"); 00427 00428 gtk_statusbar_pop(GTK_STATUSBAR(status_bar), status_id); 00429 gtk_statusbar_push(GTK_STATUSBAR(status_bar), status_id, text); 00430 } 00431 00432 put_message_in_history(text, mess_type); 00433 } 00434 00436 void cancel_button_event(GtkWidget *widget, gpointer data) 00437 { 00438 gint err = SPLT_OK; 00439 mp3splt_stop_split(the_state,&err); 00440 print_status_bar_confirmation(err); 00441 00442 if (widget != NULL) 00443 { 00444 gtk_widget_set_sensitive(widget, FALSE); 00445 } 00446 put_status_message(_(" info: stopping the split process.. please wait")); 00447 } 00448 00450 void split_button_event(GtkWidget *widget, gpointer data) 00451 { 00452 //if we are not splitting 00453 if (!we_are_splitting) 00454 { 00455 mp3splt_set_int_option(the_state, SPLT_OPT_OUTPUT_FILENAMES, 00456 SPLT_OUTPUT_DEFAULT); 00457 00458 gint err = SPLT_OK; 00459 00460 put_options_from_preferences(); 00461 00462 //output format 00463 if (mp3splt_get_int_option(the_state, SPLT_OPT_SPLIT_MODE,&err) 00464 != SPLT_OPTION_NORMAL_MODE) 00465 { 00466 if (!get_checked_output_radio_box()) 00467 { 00468 mp3splt_set_int_option(the_state, SPLT_OPT_OUTPUT_FILENAMES, 00469 SPLT_OUTPUT_FORMAT); 00470 } 00471 } 00472 00473 filename_to_split = inputfilename_get(); 00474 00475 filename_path_of_split = outputdirectory_get(); 00476 00477 if (filename_path_of_split != NULL) 00478 { 00479 we_are_splitting = TRUE; 00480 create_thread(split_it, NULL, TRUE, NULL); 00481 gtk_widget_set_sensitive(GTK_WIDGET(cancel_button), TRUE); 00482 } 00483 else 00484 { 00485 put_status_message((gchar *)_(" error: no file selected")); 00486 } 00487 } 00488 else 00489 { 00490 put_status_message((gchar *)_(" error: split in progress...")); 00491 } 00492 } 00493 00495 GtkWidget *create_toolbar() 00496 { 00497 GtkWidget *box = gtk_hbox_new(FALSE, 0); 00498 gtk_container_set_border_width(GTK_CONTAINER(box), 0); 00499 gtk_box_pack_start(GTK_BOX(box), 00500 gtk_image_new_from_stock(GTK_STOCK_APPLY, GTK_ICON_SIZE_SMALL_TOOLBAR), 00501 FALSE, FALSE, 0); 00502 gtk_box_pack_start(GTK_BOX(box), gtk_label_new(_("Split !")), FALSE, FALSE, 0); 00503 00504 GtkWidget *split_button = gtk_button_new(); 00505 gtk_container_add(GTK_CONTAINER(split_button), box); 00506 gtk_widget_set_tooltip_text(split_button,_("Split !")); 00507 gtk_container_set_border_width(GTK_CONTAINER(split_button), 0); 00508 gtk_button_set_relief(GTK_BUTTON(split_button), GTK_RELIEF_HALF); 00509 00510 g_signal_connect(G_OBJECT(split_button), "clicked", 00511 G_CALLBACK(split_button_event), NULL); 00512 00513 GtkWidget *vbox = gtk_vbox_new(FALSE, 0); 00514 GtkWidget *hbox = gtk_hbox_new(FALSE, 0); 00515 00516 gtk_box_pack_start(GTK_BOX(hbox), split_button, TRUE, FALSE, 0); 00517 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 00518 00519 return vbox; 00520 } 00521 00523 void show_messages_history_dialog(GtkWidget *widget, gpointer data) 00524 { 00525 gtk_widget_show_all(GTK_WIDGET(mess_history_dialog)); 00526 } 00527 00528 #ifndef NO_GNOME 00529 void ShowHelp() 00530 { 00531 GError* gerror = NULL; 00532 gtk_show_uri(gdk_screen_get_default(), "ghelp:mp3splt-gtk", gtk_get_current_event_time(), &gerror); 00533 } 00534 #endif 00535 00536 static gchar *my_dgettext(const gchar *key, const gchar *domain) 00537 { 00538 return dgettext("mp3splt-gtk", key); 00539 } 00540 00542 GtkWidget *create_menu_bar() 00543 { 00544 GtkWidget *menu_box = gtk_hbox_new(FALSE,0); 00545 00546 static GtkActionEntry const entries[] = { 00547 //name, stock id, label 00548 { "FileMenu", NULL, N_("_File") }, 00549 { "HelpMenu", NULL, N_("_Help") }, 00550 00551 //name, stock id, label, accelerator, tooltip 00552 { "Open", GTK_STOCK_OPEN, N_("_Open..."), "<Ctrl>O", N_("Open"), 00553 G_CALLBACK(browse_button_event) }, 00554 00555 { "Import", GTK_STOCK_FILE, N_("_Import splitpoints..."), "<Ctrl>I", N_("Import"), 00556 G_CALLBACK(import_event) }, 00557 { "Export", GTK_STOCK_SAVE_AS, N_("_Export splitpoints..."), "<Ctrl>E", N_("Export"), 00558 G_CALLBACK(ChooseCueExportFile) }, 00559 00560 { "Split", GTK_STOCK_APPLY, N_("_Split !"), "<Ctrl>S", N_("Split"), 00561 G_CALLBACK(split_button_event) }, 00562 { "Messages history", GTK_STOCK_INFO, N_("Messages _history"), "<Ctrl>H", N_("Messages history"), 00563 G_CALLBACK(show_messages_history_dialog) }, 00564 00565 { "Quit", GTK_STOCK_QUIT, N_("_Quit"), "<Ctrl>Q", N_("Quit"), 00566 G_CALLBACK(quit) }, 00567 00568 #ifndef NO_GNOME 00569 { "Contents", GTK_STOCK_HELP, N_("_Contents"), "F1", N_("Contents"), 00570 G_CALLBACK(ShowHelp)}, 00571 #endif 00572 00573 { "About", GTK_STOCK_ABOUT, N_("_About"), "<Ctrl>A", N_("About"), 00574 G_CALLBACK(about_window)}, 00575 }; 00576 00577 static const gchar *ui_info = 00578 "<ui>" 00579 " <menubar name='MenuBar'>" 00580 " <menu action='FileMenu'>" 00581 " <menuitem action='Open'/>" 00582 " <separator/>" 00583 " <menuitem action='Import'/>" 00584 " <menuitem action='Export'/>" 00585 " <separator/>" 00586 " <menuitem action='Split'/>" 00587 " <menuitem action='Messages history'/>" 00588 " <separator/>" 00589 " <menuitem action='Quit'/>" 00590 " </menu>" 00591 " <menu action='HelpMenu'>" 00592 #ifndef NO_GNOME 00593 " <menuitem action='Contents'/>" 00594 #endif 00595 " <menuitem action='About'/>" 00596 " </menu>" 00597 " </menubar>" 00598 "</ui>"; 00599 00600 GtkActionGroup *actions = gtk_action_group_new ("Actions"); 00601 00602 gtk_action_group_set_translation_domain(actions, "mp3splt-gtk"); 00603 gtk_action_group_set_translate_func(actions, 00604 (GtkTranslateFunc)my_dgettext, NULL, NULL); 00605 00606 //adding the GtkActionEntry to GtkActionGroup 00607 gtk_action_group_add_actions (actions, entries, G_N_ELEMENTS(entries), NULL); 00608 GtkUIManager *ui = gtk_ui_manager_new (); 00609 //set action to the ui 00610 gtk_ui_manager_insert_action_group (ui, actions, 0); 00611 //set the actions to the window 00612 gtk_window_add_accel_group (GTK_WINDOW (window), 00613 gtk_ui_manager_get_accel_group (ui)); 00614 //add ui from string 00615 gtk_ui_manager_add_ui_from_string(ui, ui_info, -1, NULL); 00616 00617 //attach the menu 00618 gtk_box_pack_start (GTK_BOX (menu_box), 00619 gtk_ui_manager_get_widget(ui, "/MenuBar"), 00620 FALSE, FALSE, 0); 00621 00622 GtkWidget *toolbar = (GtkWidget *)create_toolbar(); 00623 gtk_box_pack_start(GTK_BOX(menu_box), toolbar, TRUE, TRUE, 0); 00624 00625 return menu_box; 00626 } 00627 00635 GtkWidget *create_cool_button(gchar *stock_id, gchar *label_text, 00636 gint toggle_or_not) 00637 { 00638 GtkWidget *box; 00639 GtkWidget *label; 00640 GtkWidget *image; 00641 GtkWidget *button; 00642 00643 box = gtk_hbox_new(FALSE, 0); 00644 gtk_container_set_border_width(GTK_CONTAINER (box), 2); 00645 00646 image = gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_MENU); 00647 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 3); 00648 00649 if (label_text != NULL) 00650 { 00651 label = gtk_label_new (label_text); 00652 gtk_label_set_text_with_mnemonic(GTK_LABEL(label),label_text); 00653 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 3); 00654 } 00655 00656 if (toggle_or_not) 00657 { 00658 button = gtk_toggle_button_new(); 00659 } 00660 else 00661 { 00662 button = gtk_button_new(); 00663 } 00664 00665 gtk_container_add(GTK_CONTAINER(button),box); 00666 00667 return button; 00668 } 00669 00671 GtkWidget *create_main_vbox() 00672 { 00673 //big ain box contailning all with statusbar 00674 GtkWidget *main_vbox; 00675 //used for pages 00676 GtkWidget *frame; 00677 //the tree view 00678 GtkTreeView *tree_view; 00679 //the main window tabbed notebook 00680 GtkWidget *notebook; 00681 /* label for the notebook */ 00682 GtkWidget *notebook_label; 00683 00684 /* main vertical box with statusbar */ 00685 main_vbox = gtk_vbox_new (FALSE, 0); 00686 gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 0); 00687 00688 frame = (GtkWidget *)create_choose_file_frame(); 00689 gtk_box_pack_start(GTK_BOX(main_vbox), frame, FALSE, FALSE, 0); 00690 00691 /* tabbed notebook */ 00692 notebook = gtk_notebook_new(); 00693 gtk_box_pack_start (GTK_BOX (main_vbox), notebook, TRUE, TRUE, 0); 00694 gtk_notebook_popup_enable(GTK_NOTEBOOK(notebook)); 00695 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), TRUE); 00696 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE); 00697 gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), TRUE); 00698 00699 //creating the tree view 00700 GtkWidget *splitpoints_vbox; 00701 splitpoints_vbox = gtk_vbox_new (FALSE, 0); 00702 gtk_container_set_border_width (GTK_CONTAINER (splitpoints_vbox), 0); 00703 tree_view = (GtkTreeView *)create_tree_view(); 00704 frame = (GtkWidget *)create_choose_splitpoints_frame(tree_view); 00705 gtk_container_add(GTK_CONTAINER(splitpoints_vbox), frame); 00706 00707 /* player page */ 00708 player_vbox = gtk_vbox_new(FALSE,0); 00709 notebook_label = gtk_label_new((gchar *)_("Player")); 00710 00711 //player control frame 00712 player_box = (GtkWidget *)create_player_control_frame(tree_view); 00713 gtk_box_pack_start(GTK_BOX(player_vbox), player_box, FALSE, FALSE, 0); 00714 00715 //playlist control frame 00716 playlist_box = (GtkWidget *)create_player_playlist_frame(); 00717 gtk_box_pack_start(GTK_BOX(player_vbox), playlist_box, TRUE, TRUE, 0); 00718 00719 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), player_vbox, 00720 (GtkWidget *)notebook_label); 00721 00722 /* splitpoints page */ 00723 notebook_label = gtk_label_new((gchar *)_("Splitpoints")); 00724 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), 00725 splitpoints_vbox, 00726 (GtkWidget *)notebook_label); 00727 00728 /* split files frame */ 00729 GtkWidget *split_files_vbox = gtk_vbox_new (FALSE, 0); 00730 gtk_container_set_border_width(GTK_CONTAINER(split_files_vbox), 0); 00731 00732 frame = (GtkWidget *)create_split_files(); 00733 gtk_container_add(GTK_CONTAINER(split_files_vbox), frame); 00734 00735 notebook_label = gtk_label_new((gchar *)_("Split files")); 00736 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), 00737 split_files_vbox, 00738 (GtkWidget *)notebook_label); 00739 00740 /* freedb page */ 00741 GtkWidget *freedb_vbox; 00742 freedb_vbox = gtk_vbox_new (FALSE, 0); 00743 gtk_container_set_border_width (GTK_CONTAINER (freedb_vbox), 0); 00744 00745 frame = (GtkWidget *)create_freedb_frame(); 00746 gtk_container_add(GTK_CONTAINER(freedb_vbox), frame); 00747 00748 notebook_label = gtk_label_new((gchar *)_("FreeDB")); 00749 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), 00750 freedb_vbox, 00751 (GtkWidget *)notebook_label); 00752 00753 /* special split page */ 00754 GtkWidget *special_split_vbox; 00755 special_split_vbox = gtk_vbox_new (FALSE, 0); 00756 gtk_container_set_border_width (GTK_CONTAINER (special_split_vbox), 0); 00757 frame = (GtkWidget *)create_special_split_page(); 00758 gtk_container_add(GTK_CONTAINER(special_split_vbox), frame); 00759 notebook_label = gtk_label_new(_("Type of split")); 00760 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), 00761 special_split_vbox, 00762 (GtkWidget *)notebook_label); 00763 00764 /* preferences page */ 00765 GtkWidget *preferences_vbox; 00766 preferences_vbox = gtk_vbox_new (FALSE, 0); 00767 gtk_container_set_border_width (GTK_CONTAINER (preferences_vbox), 0); 00768 00769 frame = (GtkWidget *)create_choose_preferences(); 00770 gtk_container_add(GTK_CONTAINER(preferences_vbox), frame); 00771 00772 notebook_label = gtk_label_new((gchar *)_("Preferences")); 00773 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), preferences_vbox, 00774 (GtkWidget *)notebook_label); 00775 00776 /* progress bar */ 00777 percent_progress_bar = gtk_progress_bar_new(); 00778 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(percent_progress_bar), 0.0); 00779 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(percent_progress_bar), ""); 00780 00781 #if GTK_MAJOR_VERSION >= 3 00782 gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(percent_progress_bar), TRUE); 00783 #endif 00784 00785 GtkWidget *hbox = gtk_hbox_new (FALSE, 0); 00786 gtk_box_pack_start(GTK_BOX(hbox), percent_progress_bar, TRUE, TRUE, 0); 00787 00788 //stop button 00789 cancel_button = create_cool_button(GTK_STOCK_CANCEL,_("S_top"), FALSE); 00790 g_signal_connect(G_OBJECT(cancel_button), "clicked", 00791 G_CALLBACK(cancel_button_event), NULL); 00792 00793 gtk_box_pack_start(GTK_BOX(hbox), cancel_button, FALSE, TRUE, 3); 00794 gtk_widget_set_sensitive(GTK_WIDGET(cancel_button), FALSE); 00795 00796 gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, FALSE, 2); 00797 00798 /* show messages history dialog */ 00799 create_mess_history_dialog(); 00800 00801 /* statusbar */ 00802 status_bar = gtk_statusbar_new(); 00803 00804 GtkWidget *mess_history_button = 00805 create_cool_button(GTK_STOCK_INFO, NULL, FALSE); 00806 gtk_button_set_relief(GTK_BUTTON(mess_history_button), GTK_RELIEF_NONE); 00807 gtk_widget_set_tooltip_text(mess_history_button,_("Messages history")); 00808 gtk_box_pack_start(GTK_BOX(status_bar), mess_history_button, FALSE, FALSE, 0); 00809 g_signal_connect(G_OBJECT(mess_history_button), "clicked", 00810 G_CALLBACK(show_messages_history_dialog), NULL); 00811 00812 gtk_box_pack_start(GTK_BOX(main_vbox), status_bar, FALSE, FALSE, 0); 00813 00814 return main_vbox; 00815 } 00816 00817 static void move_and_resize_main_window() 00818 { 00819 const ui_main_window *main_win = ui_get_main_window_infos(ui); 00820 00821 gint x = main_win->root_x_pos; 00822 gint y = main_win->root_y_pos; 00823 00824 if (x != 0 && y != 0) 00825 { 00826 gtk_window_move(GTK_WINDOW(window), x, y); 00827 } 00828 else 00829 { 00830 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); 00831 } 00832 00833 gtk_window_resize(GTK_WINDOW(window), main_win->width, main_win->height); 00834 } 00835 00836 void create_all() 00837 { 00838 #ifdef __WIN32__ 00839 set_language(); 00840 #endif 00841 00842 initialize_window(); 00843 00844 GtkWidget *window_vbox = gtk_vbox_new(FALSE, 0); 00845 gtk_container_add(GTK_CONTAINER(window), window_vbox); 00846 00847 GtkWidget *menu_bar; 00848 menu_bar = (GtkWidget *)create_menu_bar(); 00849 gtk_box_pack_start(GTK_BOX(window_vbox), menu_bar, FALSE, FALSE, 0); 00850 00851 GtkWidget *main_vbox = (GtkWidget *)create_main_vbox(); 00852 gtk_box_pack_start(GTK_BOX(window_vbox), main_vbox, TRUE, TRUE, 0); 00853 00854 load_preferences(); 00855 00856 move_and_resize_main_window(); 00857 00858 gtk_widget_show_all(window); 00859 00860 if (selected_player != PLAYER_GSTREAMER) 00861 { 00862 gtk_widget_hide(playlist_box); 00863 } 00864 00865 hide_freedb_spinner(); 00866 } 00867 00872 void print_status_bar_confirmation(gint confirmation) 00873 { 00874 char *error_from_library = mp3splt_get_strerror(the_state, confirmation); 00875 if (error_from_library != NULL) 00876 { 00877 put_status_message(error_from_library); 00878 free(error_from_library); 00879 error_from_library = NULL; 00880 } 00881 }