mp3splt-gtk
main_win.c
Go to the documentation of this file.
1 /**********************************************************
2  *
3  * mp3splt-gtk -- utility based on mp3splt,
4  * for mp3/ogg splitting without decoding
5  *
6  * Copyright: (C) 2005-2012 Alexandru Munteanu
7  * Contact: io_fx@yahoo.fr
8  *
9  * http://mp3splt.sourceforge.net/
10  *
11  *********************************************************/
12 
13 /**********************************************************
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28  * USA.
29  *
30  *********************************************************/
31 
32 /*!********************************************************
33  * \file
34  * The main window
35  *
36  * main file that initialises the menubar, the toolbar,
37  * the tabs, about window, status error messages
38  *
39  *********************************************************/
40 
41 //we include the "config.h" file from the config options
42 #ifdef HAVE_CONFIG_H
43 #include "config.h"
44 #else
45 #define VERSION "0.7.2"
46 #define PACKAGE_NAME "mp3splt-gtk"
47 #endif
48 
49 #include <string.h>
50 #include "export.h"
51 
52 #include <gtk/gtk.h>
53 #include <glib/gi18n.h>
54 #include <libmp3splt/mp3splt.h>
55 #include <gdk/gdkkeysyms.h>
56 
57 #ifdef __WIN32__
58 #include <windows.h>
59 #include <shlwapi.h>
60 #endif
61 
62 
63 #include "util.h"
64 #include "main_win.h"
65 #include "mp3splt-gtk.h"
66 #include "tree_tab.h"
67 #include "split_files.h"
68 #include "utilities.h"
69 #include "preferences_tab.h"
70 #include "freedb_tab.h"
71 #include "special_split.h"
72 #include "utilities.h"
73 #include "player_tab.h"
74 #include "player.h"
75 #include "messages.h"
76 #include "import.h"
77 #include "preferences_manager.h"
78 #include "player_tab.h"
79 
80 #include "ui_manager.h"
81 
82 //main window
83 GtkWidget *window = NULL;
84 GtkAccelGroup *window_accel_group = NULL;
85 
86 //status bar
87 GtkWidget *status_bar;
88 
89 //if we are on the preferences tab, then TRUE
90 gint preferences_tab = FALSE;
91 
92 //player box
93 GtkWidget *player_box;
94 
95 //the split freedb button
96 GtkWidget *split_freedb_button;
97 
98 //new window for the progress bar
99 GtkWidget *percent_progress_bar;
100 
101 //filename and path for the file to split
102 gchar *filename_to_split;
103 gchar *filename_path_of_split;
104 
105 //if we are currently splitting
106 gint we_are_splitting = FALSE;
107 gint we_quit_main_program = FALSE;
108 
109 GtkWidget *player_vbox = NULL;
110 
111 //stop button to cancel the split
112 GtkWidget *cancel_button = NULL;
113 
114 extern GtkWidget *mess_history_dialog;
115 
116 extern GtkWidget *da;
117 extern GtkWidget *progress_bar;
118 
119 extern GArray *splitpoints;
120 extern gint selected_id;
121 extern splt_state *the_state;
122 extern splt_freedb_results *search_results;
123 extern GList *player_pref_list;
124 extern GList *text_options_list;
125 extern gchar **split_files;
126 extern gint max_split_files;
127 extern gint selected_player;
128 extern silence_wave *silence_points;
129 extern gint number_of_silence_points;
130 
131 extern ui_state *ui;
132 
133 GtkWidget *playlist_box = NULL;
134 
135 //close the window and exit button function
136 void quit(GtkWidget *widget, gpointer data)
137 {
138  save_preferences(NULL, NULL);
139 
140  if (we_are_splitting)
141  {
142  gint err = SPLT_OK;
143  mp3splt_stop_split(the_state,&err);
145 
146  we_quit_main_program = TRUE;
147  put_status_message(_(" info: stopping the split process before exiting"));
148  }
149 
150  //quit the player: currently closes gstreamer
151  if (player_is_running())
152  {
153  player_quit();
154  }
155 
156  g_list_free(player_pref_list);
157  g_list_free(text_options_list);
158  g_array_free(splitpoints, TRUE);
159 
160  if (silence_points)
161  {
162  g_free(silence_points);
163  silence_points = NULL;
164  number_of_silence_points = 0;
165  }
166 
167  gtk_main_quit();
168 }
169 
170 void main_window_drag_data_received(GtkWidget *window,
171  GdkDragContext *drag_context, gint x, gint y, GtkSelectionData *data, guint
172  info, guint time, gpointer user_data)
173 {
174  const gchar *received_data = (gchar *) gtk_selection_data_get_text(data);
175 
176  if (received_data != NULL)
177  {
178  gchar **drop_filenames = NULL;
179  drop_filenames = g_strsplit(received_data, "\n", 0);
180 
181  gint current_index = 0;
182  gchar *current_filename = drop_filenames[current_index];
183  while (current_filename != NULL)
184  {
185  gchar *filename = NULL;
186  if (strstr(current_filename, "file:") == current_filename)
187  {
188  filename = g_filename_from_uri(current_filename, NULL, NULL);
189  }
190  else
191  {
192  gint fname_malloc_size = strlen(current_filename) + 1;
193  filename = g_malloc(sizeof(gchar) * fname_malloc_size);
194  g_snprintf(filename, fname_malloc_size, "%s", current_filename);
195  }
196 
198 
199  if (is_filee(filename))
200  {
201  handle_import(filename);
202  }
203 
204  if (filename)
205  {
206  g_free(filename);
207  filename = NULL;
208  }
209 
210  g_free(current_filename);
211  current_index++;
212  current_filename = drop_filenames[current_index];
213  }
214 
215  if (drop_filenames)
216  {
217  g_free(drop_filenames);
218  drop_filenames = NULL;
219  }
220  }
221 }
222 
223 gboolean configure_window_callback(GtkWindow *window, GdkEvent *event, gpointer data)
224 {
225  ui_state *ui = (ui_state *)data;
226 
227  ui_set_main_win_position(ui, event->configure.x, event->configure.y);
228  ui_set_main_win_size(ui, event->configure.width, event->configure.height);
229 
230  return FALSE;
231 }
232 
233 void initialize_window()
234 {
235  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
236 
237  g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(configure_window_callback), ui);
238 
239  window_accel_group = gtk_accel_group_new();
240  gtk_window_add_accel_group(GTK_WINDOW(window), window_accel_group);
241 
242  gtk_window_set_title(GTK_WINDOW(window), PACKAGE_NAME" "VERSION);
243  gtk_container_set_border_width (GTK_CONTAINER (window), 0);
244 
245  g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(quit), NULL);
246  g_signal_connect(G_OBJECT(window), "drag-data-received",
247  G_CALLBACK(main_window_drag_data_received), NULL);
248  gtk_drag_dest_set(window, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
249  drop_types, 3, GDK_ACTION_COPY | GDK_ACTION_MOVE);
250 
251  GString *Imagefile = g_string_new("");
252  build_path(Imagefile, PIXMAP_PATH, "mp3splt-gtk_ico"ICON_EXT);
253  GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(Imagefile->str, NULL);
254  gtk_window_set_default_icon(pixbuf);
255  g_string_free(Imagefile, TRUE);
256 }
257 
258 void activate_url(GtkAboutDialog *about, const gchar *link, gpointer data)
259 {
260 #ifdef __WIN32__
261  char default_browser[512] = { '\0' };
262  DWORD dwType, dwSize = sizeof(default_browser) - 1;
263 
264  SHGetValue(HKEY_CURRENT_USER,
265  TEXT("Software\\Clients\\StartMenuInternet"),
266  TEXT(""),
267  &dwType,
268  default_browser,
269  &dwSize);
270 
271  if (default_browser[0] != '\0')
272  {
273  SHGetValue(HKEY_LOCAL_MACHINE,
274  TEXT("SOFTWARE\\Clients\\StartMenuInternet"),
275  TEXT(""),
276  &dwType,
277  default_browser,
278  &dwSize);
279  }
280 
281  if (default_browser[0] != '\0')
282  {
283  char browser_exe[2048] = { '\0' };
284  dwSize = sizeof(browser_exe) - 1;
285 
286  char browser_exe_registry[1024] = { '\0' };
287  snprintf(browser_exe_registry, 1024,
288  "SOFTWARE\\Clients\\StartMenuInternet\\%s\\shell\\open\\command\\",
289  default_browser);
290 
291  SHGetValue(HKEY_LOCAL_MACHINE,
292  TEXT(browser_exe_registry), TEXT(""),
293  &dwType, browser_exe, &dwSize);
294 
295  if (browser_exe[0] != '\0')
296  {
297  gint browser_command_size = strlen(browser_exe) + strlen(link) + 2;
298  char *browser_command = g_malloc(sizeof(char) * browser_command_size);
299  if (browser_command)
300  {
301  snprintf(browser_command, browser_command_size, "%s %s",
302  browser_exe, link);
303 
304  STARTUPINFO si;
305  PROCESS_INFORMATION pinf;
306  ZeroMemory(&si, sizeof(si));
307  si.cb = sizeof(si);
308  ZeroMemory(&pinf, sizeof(pinf));
309 
310  if (! CreateProcess(NULL, browser_command,
311  NULL, NULL, FALSE, 0, NULL, NULL, &si, &pinf))
312  {
313  put_status_message(_("Error launching external command"));
314  }
315 
316  CloseHandle(pinf.hProcess);
317  CloseHandle(pinf.hThread);
318 
319  g_free(browser_command);
320  browser_command = NULL;
321  }
322  }
323  }
324 #endif
325 }
326 
327 void about_window(GtkWidget *widget, gpointer *data)
328 {
329  GtkWidget *dialog = gtk_about_dialog_new();
330 
331  GString *Imagefile = g_string_new("");
332  build_path(Imagefile, PIXMAP_PATH, "mp3splt-gtk.png");
333  GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(Imagefile->str, NULL);
334  gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dialog), pixbuf);
335  g_string_free(Imagefile, TRUE);
336 
337  gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(dialog), (gchar *)PACKAGE_NAME);
338  gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog), VERSION);
339  gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(dialog),
340  PACKAGE_NAME" : Copyright © 2005-2011 Alexandru"
341  " Munteanu \n mp3splt : Copyright © 2002-2005 Matteo Trotta");
342 
343  gchar *b1 = NULL;
344  gchar b3[100] = { '\0' };
345  b1 = (gchar *)_("using");
346  gchar library_version[20] = { '\0' };
347  mp3splt_get_version(library_version);
348  g_snprintf(b3, 100, "-%s-\n%s libmp3splt %s",
349  _("release of "MP3SPLT_GTK_DATE), b1, library_version);
350 
351  gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(dialog), b3);
352 
353  gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(dialog),
354  "\n"
355  "This program is free software; you can "
356  "redistribute it and/or \n"
357  "modify it under the terms of the GNU General Public License\n"
358  "as published by the Free Software "
359  "Foundation; either version 2\n"
360  "of the License, or (at your option) "
361  "any later version.\n\n"
362  "This program is distributed in the "
363  "hope that it will be useful,\n"
364  "but WITHOUT ANY WARRANTY; without even "
365  "the implied warranty of\n"
366  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
367  "GNU General Public License for more details.\n\n"
368  "You should have received a copy of the GNU General Public License\n"
369  "along with this program; if not, write "
370  "to the Free Software\n"
371  "Foundation, Inc., 59 Temple Place -"
372  "Suite 330, Boston, MA 02111-1307, "
373  "USA.");
374 
375  g_signal_connect(G_OBJECT(dialog), "activate-link", G_CALLBACK(activate_url), NULL);
376 
377  gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(dialog),
378  "http://mp3splt.sourceforge.net");
379  gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(dialog),
380  "http://mp3splt.sourceforge.net");
381 
382  gtk_about_dialog_set_translator_credits(GTK_ABOUT_DIALOG(dialog),
383  "Mario Blättermann <mariobl@gnome.org>");
384 
385  gtk_dialog_run(GTK_DIALOG(dialog));
386  gtk_widget_destroy(dialog);
387 }
388 
394 {
395  guint status_id =
396  gtk_statusbar_get_context_id(GTK_STATUSBAR(status_bar), "mess");
397  gtk_statusbar_pop(GTK_STATUSBAR(status_bar), status_id);
398 }
399 
407 void put_status_message(const gchar *text)
408 {
410 }
411 
421 void put_status_message_with_type(const gchar *text, splt_message_type mess_type)
422 {
423  if (mess_type == SPLT_MESSAGE_INFO)
424  {
425  guint status_id =
426  gtk_statusbar_get_context_id(GTK_STATUSBAR(status_bar), "mess");
427 
428  gtk_statusbar_pop(GTK_STATUSBAR(status_bar), status_id);
429  gtk_statusbar_push(GTK_STATUSBAR(status_bar), status_id, text);
430  }
431 
432  put_message_in_history(text, mess_type);
433 }
434 
436 void cancel_button_event(GtkWidget *widget, gpointer data)
437 {
438  gint err = SPLT_OK;
439  mp3splt_stop_split(the_state,&err);
441 
442  if (widget != NULL)
443  {
444  gtk_widget_set_sensitive(widget, FALSE);
445  }
446  put_status_message(_(" info: stopping the split process.. please wait"));
447 }
448 
450 void split_button_event(GtkWidget *widget, gpointer data)
451 {
452  //if we are not splitting
453  if (!we_are_splitting)
454  {
455  mp3splt_set_int_option(the_state, SPLT_OPT_OUTPUT_FILENAMES,
457 
458  gint err = SPLT_OK;
459 
461 
462  //output format
463  if (mp3splt_get_int_option(the_state, SPLT_OPT_SPLIT_MODE,&err)
465  {
467  {
468  mp3splt_set_int_option(the_state, SPLT_OPT_OUTPUT_FILENAMES,
470  }
471  }
472 
473  filename_to_split = inputfilename_get();
474 
475  filename_path_of_split = outputdirectory_get();
476 
477  if (filename_path_of_split != NULL)
478  {
479  we_are_splitting = TRUE;
480  create_thread(split_it, NULL, TRUE, NULL);
481  gtk_widget_set_sensitive(GTK_WIDGET(cancel_button), TRUE);
482  }
483  else
484  {
485  put_status_message((gchar *)_(" error: no file selected"));
486  }
487  }
488  else
489  {
490  put_status_message((gchar *)_(" error: split in progress..."));
491  }
492 }
493 
495 GtkWidget *create_toolbar()
496 {
497  GtkWidget *box = gtk_hbox_new(FALSE, 0);
498  gtk_container_set_border_width(GTK_CONTAINER(box), 0);
499  gtk_box_pack_start(GTK_BOX(box),
500  gtk_image_new_from_stock(GTK_STOCK_APPLY, GTK_ICON_SIZE_SMALL_TOOLBAR),
501  FALSE, FALSE, 0);
502  gtk_box_pack_start(GTK_BOX(box), gtk_label_new(_("Split !")), FALSE, FALSE, 0);
503 
504  GtkWidget *split_button = gtk_button_new();
505  gtk_container_add(GTK_CONTAINER(split_button), box);
506  gtk_widget_set_tooltip_text(split_button,_("Split !"));
507  gtk_container_set_border_width(GTK_CONTAINER(split_button), 0);
508  gtk_button_set_relief(GTK_BUTTON(split_button), GTK_RELIEF_HALF);
509 
510  g_signal_connect(G_OBJECT(split_button), "clicked",
511  G_CALLBACK(split_button_event), NULL);
512 
513  GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
514  GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
515 
516  gtk_box_pack_start(GTK_BOX(hbox), split_button, TRUE, FALSE, 0);
517  gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
518 
519  return vbox;
520 }
521 
523 void show_messages_history_dialog(GtkWidget *widget, gpointer data)
524 {
525  gtk_widget_show_all(GTK_WIDGET(mess_history_dialog));
526 }
527 
528 #ifndef NO_GNOME
529 void ShowHelp()
530 {
531  GError* gerror = NULL;
532  gtk_show_uri(gdk_screen_get_default(), "ghelp:mp3splt-gtk", gtk_get_current_event_time(), &gerror);
533 }
534 #endif
535 
536 static gchar *my_dgettext(const gchar *key, const gchar *domain)
537 {
538  return dgettext("mp3splt-gtk", key);
539 }
540 
542 GtkWidget *create_menu_bar()
543 {
544  GtkWidget *menu_box = gtk_hbox_new(FALSE,0);
545 
546  static GtkActionEntry const entries[] = {
547  //name, stock id, label
548  { "FileMenu", NULL, N_("_File") },
549  { "HelpMenu", NULL, N_("_Help") },
550 
551  //name, stock id, label, accelerator, tooltip
552  { "Open", GTK_STOCK_OPEN, N_("_Open..."), "<Ctrl>O", N_("Open"),
553  G_CALLBACK(browse_button_event) },
554 
555  { "Import", GTK_STOCK_FILE, N_("_Import splitpoints..."), "<Ctrl>I", N_("Import"),
556  G_CALLBACK(import_event) },
557  { "Export", GTK_STOCK_SAVE_AS, N_("_Export splitpoints..."), "<Ctrl>E", N_("Export"),
558  G_CALLBACK(ChooseCueExportFile) },
559 
560  { "Split", GTK_STOCK_APPLY, N_("_Split !"), "<Ctrl>S", N_("Split"),
561  G_CALLBACK(split_button_event) },
562  { "Messages history", GTK_STOCK_INFO, N_("Messages _history"), "<Ctrl>H", N_("Messages history"),
563  G_CALLBACK(show_messages_history_dialog) },
564 
565  { "Quit", GTK_STOCK_QUIT, N_("_Quit"), "<Ctrl>Q", N_("Quit"),
566  G_CALLBACK(quit) },
567 
568 #ifndef NO_GNOME
569  { "Contents", GTK_STOCK_HELP, N_("_Contents"), "F1", N_("Contents"),
570  G_CALLBACK(ShowHelp)},
571 #endif
572 
573  { "About", GTK_STOCK_ABOUT, N_("_About"), "<Ctrl>A", N_("About"),
574  G_CALLBACK(about_window)},
575  };
576 
577  static const gchar *ui_info =
578  "<ui>"
579  " <menubar name='MenuBar'>"
580  " <menu action='FileMenu'>"
581  " <menuitem action='Open'/>"
582  " <separator/>"
583  " <menuitem action='Import'/>"
584  " <menuitem action='Export'/>"
585  " <separator/>"
586  " <menuitem action='Split'/>"
587  " <menuitem action='Messages history'/>"
588  " <separator/>"
589  " <menuitem action='Quit'/>"
590  " </menu>"
591  " <menu action='HelpMenu'>"
592 #ifndef NO_GNOME
593  " <menuitem action='Contents'/>"
594 #endif
595  " <menuitem action='About'/>"
596  " </menu>"
597  " </menubar>"
598  "</ui>";
599 
600  GtkActionGroup *actions = gtk_action_group_new ("Actions");
601 
602  gtk_action_group_set_translation_domain(actions, "mp3splt-gtk");
603  gtk_action_group_set_translate_func(actions,
604  (GtkTranslateFunc)my_dgettext, NULL, NULL);
605 
606  //adding the GtkActionEntry to GtkActionGroup
607  gtk_action_group_add_actions (actions, entries, G_N_ELEMENTS(entries), NULL);
608  GtkUIManager *ui = gtk_ui_manager_new ();
609  //set action to the ui
610  gtk_ui_manager_insert_action_group (ui, actions, 0);
611  //set the actions to the window
612  gtk_window_add_accel_group (GTK_WINDOW (window),
613  gtk_ui_manager_get_accel_group (ui));
614  //add ui from string
615  gtk_ui_manager_add_ui_from_string(ui, ui_info, -1, NULL);
616 
617  //attach the menu
618  gtk_box_pack_start (GTK_BOX (menu_box),
619  gtk_ui_manager_get_widget(ui, "/MenuBar"),
620  FALSE, FALSE, 0);
621 
622  GtkWidget *toolbar = (GtkWidget *)create_toolbar();
623  gtk_box_pack_start(GTK_BOX(menu_box), toolbar, TRUE, TRUE, 0);
624 
625  return menu_box;
626 }
627 
635 GtkWidget *create_cool_button(gchar *stock_id, gchar *label_text,
636  gint toggle_or_not)
637 {
638  GtkWidget *box;
639  GtkWidget *label;
640  GtkWidget *image;
641  GtkWidget *button;
642 
643  box = gtk_hbox_new(FALSE, 0);
644  gtk_container_set_border_width(GTK_CONTAINER (box), 2);
645 
646  image = gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_MENU);
647  gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 3);
648 
649  if (label_text != NULL)
650  {
651  label = gtk_label_new (label_text);
652  gtk_label_set_text_with_mnemonic(GTK_LABEL(label),label_text);
653  gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 3);
654  }
655 
656  if (toggle_or_not)
657  {
658  button = gtk_toggle_button_new();
659  }
660  else
661  {
662  button = gtk_button_new();
663  }
664 
665  gtk_container_add(GTK_CONTAINER(button),box);
666 
667  return button;
668 }
669 
671 GtkWidget *create_main_vbox()
672 {
673  //big ain box contailning all with statusbar
674  GtkWidget *main_vbox;
675  //used for pages
676  GtkWidget *frame;
677  //the tree view
678  GtkTreeView *tree_view;
679  //the main window tabbed notebook
680  GtkWidget *notebook;
681  /* label for the notebook */
682  GtkWidget *notebook_label;
683 
684  /* main vertical box with statusbar */
685  main_vbox = gtk_vbox_new (FALSE, 0);
686  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 0);
687 
688  frame = (GtkWidget *)create_choose_file_frame();
689  gtk_box_pack_start(GTK_BOX(main_vbox), frame, FALSE, FALSE, 0);
690 
691  /* tabbed notebook */
692  notebook = gtk_notebook_new();
693  gtk_box_pack_start (GTK_BOX (main_vbox), notebook, TRUE, TRUE, 0);
694  gtk_notebook_popup_enable(GTK_NOTEBOOK(notebook));
695  gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), TRUE);
696  gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE);
697  gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), TRUE);
698 
699  //creating the tree view
700  GtkWidget *splitpoints_vbox;
701  splitpoints_vbox = gtk_vbox_new (FALSE, 0);
702  gtk_container_set_border_width (GTK_CONTAINER (splitpoints_vbox), 0);
703  tree_view = (GtkTreeView *)create_tree_view();
704  frame = (GtkWidget *)create_choose_splitpoints_frame(tree_view);
705  gtk_container_add(GTK_CONTAINER(splitpoints_vbox), frame);
706 
707  /* player page */
708  player_vbox = gtk_vbox_new(FALSE,0);
709  notebook_label = gtk_label_new((gchar *)_("Player"));
710 
711  //player control frame
712  player_box = (GtkWidget *)create_player_control_frame(tree_view);
713  gtk_box_pack_start(GTK_BOX(player_vbox), player_box, FALSE, FALSE, 0);
714 
715  //playlist control frame
716  playlist_box = (GtkWidget *)create_player_playlist_frame();
717  gtk_box_pack_start(GTK_BOX(player_vbox), playlist_box, TRUE, TRUE, 0);
718 
719  gtk_notebook_append_page(GTK_NOTEBOOK(notebook), player_vbox,
720  (GtkWidget *)notebook_label);
721 
722  /* splitpoints page */
723  notebook_label = gtk_label_new((gchar *)_("Splitpoints"));
724  gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
725  splitpoints_vbox,
726  (GtkWidget *)notebook_label);
727 
728  /* split files frame */
729  GtkWidget *split_files_vbox = gtk_vbox_new (FALSE, 0);
730  gtk_container_set_border_width(GTK_CONTAINER(split_files_vbox), 0);
731 
732  frame = (GtkWidget *)create_split_files();
733  gtk_container_add(GTK_CONTAINER(split_files_vbox), frame);
734 
735  notebook_label = gtk_label_new((gchar *)_("Split files"));
736  gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
737  split_files_vbox,
738  (GtkWidget *)notebook_label);
739 
740  /* freedb page */
741  GtkWidget *freedb_vbox;
742  freedb_vbox = gtk_vbox_new (FALSE, 0);
743  gtk_container_set_border_width (GTK_CONTAINER (freedb_vbox), 0);
744 
745  frame = (GtkWidget *)create_freedb_frame();
746  gtk_container_add(GTK_CONTAINER(freedb_vbox), frame);
747 
748  notebook_label = gtk_label_new((gchar *)_("FreeDB"));
749  gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
750  freedb_vbox,
751  (GtkWidget *)notebook_label);
752 
753  /* special split page */
754  GtkWidget *special_split_vbox;
755  special_split_vbox = gtk_vbox_new (FALSE, 0);
756  gtk_container_set_border_width (GTK_CONTAINER (special_split_vbox), 0);
757  frame = (GtkWidget *)create_special_split_page();
758  gtk_container_add(GTK_CONTAINER(special_split_vbox), frame);
759  notebook_label = gtk_label_new(_("Type of split"));
760  gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
761  special_split_vbox,
762  (GtkWidget *)notebook_label);
763 
764  /* preferences page */
765  GtkWidget *preferences_vbox;
766  preferences_vbox = gtk_vbox_new (FALSE, 0);
767  gtk_container_set_border_width (GTK_CONTAINER (preferences_vbox), 0);
768 
769  frame = (GtkWidget *)create_choose_preferences();
770  gtk_container_add(GTK_CONTAINER(preferences_vbox), frame);
771 
772  notebook_label = gtk_label_new((gchar *)_("Preferences"));
773  gtk_notebook_append_page(GTK_NOTEBOOK(notebook), preferences_vbox,
774  (GtkWidget *)notebook_label);
775 
776  /* progress bar */
777  percent_progress_bar = gtk_progress_bar_new();
778  gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(percent_progress_bar), 0.0);
779  gtk_progress_bar_set_text(GTK_PROGRESS_BAR(percent_progress_bar), "");
780 
781 #if GTK_MAJOR_VERSION >= 3
782  gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(percent_progress_bar), TRUE);
783 #endif
784 
785  GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
786  gtk_box_pack_start(GTK_BOX(hbox), percent_progress_bar, TRUE, TRUE, 0);
787 
788  //stop button
789  cancel_button = create_cool_button(GTK_STOCK_CANCEL,_("S_top"), FALSE);
790  g_signal_connect(G_OBJECT(cancel_button), "clicked",
791  G_CALLBACK(cancel_button_event), NULL);
792 
793  gtk_box_pack_start(GTK_BOX(hbox), cancel_button, FALSE, TRUE, 3);
794  gtk_widget_set_sensitive(GTK_WIDGET(cancel_button), FALSE);
795 
796  gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, FALSE, 2);
797 
798  /* show messages history dialog */
800 
801  /* statusbar */
802  status_bar = gtk_statusbar_new();
803 
804  GtkWidget *mess_history_button =
805  create_cool_button(GTK_STOCK_INFO, NULL, FALSE);
806  gtk_button_set_relief(GTK_BUTTON(mess_history_button), GTK_RELIEF_NONE);
807  gtk_widget_set_tooltip_text(mess_history_button,_("Messages history"));
808  gtk_box_pack_start(GTK_BOX(status_bar), mess_history_button, FALSE, FALSE, 0);
809  g_signal_connect(G_OBJECT(mess_history_button), "clicked",
810  G_CALLBACK(show_messages_history_dialog), NULL);
811 
812  gtk_box_pack_start(GTK_BOX(main_vbox), status_bar, FALSE, FALSE, 0);
813 
814  return main_vbox;
815 }
816 
817 static void move_and_resize_main_window()
818 {
819  const ui_main_window *main_win = ui_get_main_window_infos(ui);
820 
821  gint x = main_win->root_x_pos;
822  gint y = main_win->root_y_pos;
823 
824  if (x != 0 && y != 0)
825  {
826  gtk_window_move(GTK_WINDOW(window), x, y);
827  }
828  else
829  {
830  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
831  }
832 
833  gtk_window_resize(GTK_WINDOW(window), main_win->width, main_win->height);
834 }
835 
836 void create_all()
837 {
838 #ifdef __WIN32__
839  set_language();
840 #endif
841 
842  initialize_window();
843 
844  GtkWidget *window_vbox = gtk_vbox_new(FALSE, 0);
845  gtk_container_add(GTK_CONTAINER(window), window_vbox);
846 
847  GtkWidget *menu_bar;
848  menu_bar = (GtkWidget *)create_menu_bar();
849  gtk_box_pack_start(GTK_BOX(window_vbox), menu_bar, FALSE, FALSE, 0);
850 
851  GtkWidget *main_vbox = (GtkWidget *)create_main_vbox();
852  gtk_box_pack_start(GTK_BOX(window_vbox), main_vbox, TRUE, TRUE, 0);
853 
855 
856  move_and_resize_main_window();
857 
858  gtk_widget_show_all(window);
859 
860  if (selected_player != PLAYER_GSTREAMER)
861  {
862  gtk_widget_hide(playlist_box);
863  }
864 
865  hide_freedb_spinner();
866 }
867 
872 void print_status_bar_confirmation(gint confirmation)
873 {
874  char *error_from_library = mp3splt_get_strerror(the_state, confirmation);
875  if (error_from_library != NULL)
876  {
877  put_status_message(error_from_library);
878  free(error_from_library);
879  error_from_library = NULL;
880  }
881 }