Ejemplo n.º 1
0
static int motion_callback(void * data, int x, int y, int mask)
  {
  visualizer_t * v = (visualizer_t*)data;
  if(v->toolbar_trigger & TOOLBAR_TRIGGER_MOUSE)
    show_toolbar(v);
  return FALSE;
  }
Ejemplo n.º 2
0
static gboolean key_callback(GtkWidget * w,
                             GdkEventKey * evt,
                             gpointer data)
  {
  visualizer_t * v = (visualizer_t*)data;
  
  //  gtk_widget_show(v->toolbar);
  //  g_timeout_add(2000, toolbar_timeout, v);
  switch(evt->keyval)
    {
    case GDK_Tab:
    case GDK_f:
      toggle_fullscreen(v);
      return TRUE;
      break;
    case GDK_Escape:
      if(v->current_window == &v->fullscreen_window)
        toggle_fullscreen(v);
      return TRUE;
      break;
    case GDK_Menu:
      if(v->toolbar_trigger & TOOLBAR_TRIGGER_KEY)
        show_toolbar(v);
      return TRUE;
      break;
    }
  return FALSE;
  }
Ejemplo n.º 3
0
static gboolean window_motion_callback(GtkWidget      *widget,
                                       GdkEventMotion *event,
                                       gpointer        data)
  {
  visualizer_t * v = (visualizer_t*)data;
  if(v->toolbar_trigger & TOOLBAR_TRIGGER_MOUSE)
    show_toolbar(v);
  return FALSE;
  }
Ejemplo n.º 4
0
GtkWidget *snd_as_widget(int argc, char **argv, GtkWidget *parent, void (*error_func)(const char *msg))
{

#else

void snd_doit(int argc, char **argv)
{
#endif
  GtkWidget *shell;
  int i;

#ifdef SND_AS_WIDGET
  set_error_display(error_func);
  ss = snd_main(argc, argv);
#else
  gtk_init(&argc, &argv);

#if (!HAVE_GTK_3)
#ifndef HAVE_OSX
  gdk_set_locale();
#endif
#endif

#endif

  ss->channel_min_height = CHANNEL_MIN_HEIGHT;
  ss->Graph_Cursor = DEFAULT_GRAPH_CURSOR;

#ifndef SND_AS_WIDGET
  shell = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  sg_make_resizable(shell);
#endif

  auto_open_files = argc-1;
  if (argc > 1) auto_open_file_names = (char **)(argv + 1);
  ss->startup_title = mus_strdup("snd");
  set_sound_style(SOUNDS_VERTICAL);
  for (i = 1; i < argc; i++)
    if ((strcmp(argv[i], "-h") == 0) || 
	(strcmp(argv[i], "-horizontal") == 0) ||
	(strcmp(argv[i], "--horizontal") == 0))
      set_sound_style(SOUNDS_HORIZONTAL);
    else
      if ((strcmp(argv[i], "-v") == 0) || 
	  (strcmp(argv[i], "-vertical") == 0) ||
	  (strcmp(argv[i], "--vertical") == 0))
	set_sound_style(SOUNDS_VERTICAL);
      else
	if ((strcmp(argv[i], "-notebook") == 0) ||
	    (strcmp(argv[i], "--notebook") == 0))
	  set_sound_style(SOUNDS_IN_NOTEBOOK);
	else
	  if ((strcmp(argv[i], "-separate") == 0) ||
	      (strcmp(argv[i], "--separate") == 0))
	    set_sound_style(SOUNDS_IN_SEPARATE_WINDOWS);
	  else
	    if (strcmp(argv[i], "-noglob") == 0)
	      noglob = true;
	    else
	      if (strcmp(argv[i], "-noinit") == 0)
		noinit = true;
	      else
		if (strcmp(argv[i], "-nostdin") == 0)
		  nostdin = true;
		else
		  if ((strcmp(argv[i], "-b") == 0) || 
		      (strcmp(argv[i], "-batch") == 0) ||
		      (strcmp(argv[i], "--batch") == 0))
		    batch = true;
		  else
		    if (strcmp(argv[i], "--features") == 0) /* testing (compsnd) */
		      check_features_list(argv[i + 1]);

  ss->batch_mode = batch;
  set_auto_resize(AUTO_RESIZE_DEFAULT);
  ss->zoom_slider_width = ZOOM_SLIDER_WIDTH;
  ss->position_slider_width = POSITION_SLIDER_WIDTH;
  ss->channel_sash_indent = CHANNEL_SASH_INDENT; /* not currently used */
  ss->channel_sash_size = CHANNEL_SASH_SIZE;
  ss->sash_size = SASH_SIZE;
  ss->sash_indent = SASH_INDENT;
  ss->toggle_size = TOGGLE_SIZE;
  ss->graph_is_active = false;
  ss->bg_gradient = 0.05;

  ss->white =                         WHITE_COLOR;
  ss->black =                         BLACK_COLOR;
  ss->light_blue =                    LIGHT_BLUE_COLOR;
  ss->lighter_blue =                  LIGHTER_BLUE_COLOR;
  ss->red =                           RED_COLOR;
  ss->green =                         GREEN_COLOR;
  ss->blue =                          BLUE_COLOR;
  ss->yellow =                        YELLOW_COLOR;
  ss->highlight_color =               HIGHLIGHT_COLOR;
  ss->basic_color =                   BASIC_COLOR;
  ss->position_color =                POSITION_COLOR;
  ss->zoom_color =                    ZOOM_COLOR;
  ss->cursor_color =                  CURSOR_COLOR;
  ss->selection_color =               SELECTION_COLOR;
  ss->mix_color =                     MIX_COLOR;
  ss->enved_waveform_color =          ENVED_WAVEFORM_COLOR;
  ss->filter_control_waveform_color = FILTER_CONTROL_WAVEFORM_COLOR;
  ss->listener_color =                LISTENER_COLOR;
  ss->listener_text_color =           LISTENER_TEXT_COLOR;
  ss->graph_color =                   GRAPH_COLOR;
  ss->selected_graph_color =          SELECTED_GRAPH_COLOR;
  ss->data_color =                    DATA_COLOR;
  ss->selected_data_color =           SELECTED_DATA_COLOR;
  ss->mark_color =                    MARK_COLOR;
  ss->sash_color =                    SASH_COLOR;
  ss->text_focus_color =              TEXT_FOCUS_COLOR;

  ss->grid_color = get_in_between_color(ss->data_color, ss->graph_color);
  ss->selected_grid_color = get_in_between_color(ss->selected_data_color, ss->selected_graph_color);

  ss->axis_color_set = false;

  ss->orig_data_color = ss->data_color;
  ss->orig_selected_data_color = ss->selected_data_color;
  ss->orig_mark_color = ss->mark_color;
  ss->orig_mix_color = ss->mix_color;
  ss->orig_graph_color = ss->graph_color;
  ss->orig_selected_graph_color = ss->selected_graph_color;
  ss->orig_listener_color = ss->listener_color;
  ss->orig_listener_text_color = ss->listener_text_color;
  ss->orig_cursor_color = ss->cursor_color;
  ss->orig_basic_color = ss->basic_color;
  ss->orig_selection_color = ss->selection_color;
  ss->orig_zoom_color = ss->zoom_color;
  ss->orig_position_color = ss->position_color;
  ss->orig_highlight_color = ss->highlight_color;

  if ((!(set_tiny_font(DEFAULT_TINY_FONT))) &&
      (!(set_tiny_font(FALLBACK_FONT))))
    fprintf(stderr, "can't find tiny font: %s", DEFAULT_TINY_FONT);

  if ((!(set_axis_label_font(DEFAULT_AXIS_LABEL_FONT))) &&
      (!(set_axis_label_font(FALLBACK_FONT))))
    fprintf(stderr, "can't find axis label font: %s", DEFAULT_AXIS_LABEL_FONT);

  if ((!(set_axis_numbers_font(DEFAULT_AXIS_NUMBERS_FONT))) &&
      (!(set_axis_numbers_font(FALLBACK_FONT))))
    fprintf(stderr, "can't find axis numbers font: %s", DEFAULT_AXIS_NUMBERS_FONT);

  if ((!(set_peaks_font(DEFAULT_PEAKS_FONT))) &&
      (!(set_peaks_font(FALLBACK_FONT))))
    fprintf(stderr, "can't find peaks font: %s", DEFAULT_PEAKS_FONT);

  if ((!(set_bold_peaks_font(DEFAULT_BOLD_PEAKS_FONT))) &&
      (!(set_bold_peaks_font(FALLBACK_FONT))))
    fprintf(stderr, "can't find bold peaks font: %s", DEFAULT_BOLD_PEAKS_FONT);

  if (!(set_listener_font(FALLBACK_FONT)))
    fprintf(stderr, "can't find listener font: %s", FALLBACK_FONT);

  ss->orig_axis_label_font = mus_strdup(axis_label_font(ss));
  ss->orig_axis_numbers_font = mus_strdup(axis_numbers_font(ss));
  ss->orig_peaks_font = mus_strdup(peaks_font(ss));
  ss->orig_bold_peaks_font = mus_strdup(bold_peaks_font(ss));
  ss->orig_listener_font = mus_strdup(listener_font(ss));
  ss->orig_tiny_font = mus_strdup(tiny_font(ss));

#if (!HAVE_GTK_3)
  init_gtk();
#endif

  MAIN_PANE(ss) = gtk_vbox_new(false, 0); /* not homogenous, spacing 0 */

#if (HAVE_GTK_3)
  init_gtk();
#endif
  
#ifdef SND_AS_WIDGET
  MAIN_SHELL(ss) = parent;
  shell = MAIN_PANE(ss);
#else
  MAIN_SHELL(ss) = shell;
  gtk_container_add(GTK_CONTAINER(MAIN_SHELL(ss)), MAIN_PANE(ss));
#endif
  add_menu(); /* adds menubar to MAIN_PANE (via box_pack_start) */
  if (with_toolbar(ss)) show_toolbar();

  if (sound_style(ss) != SOUNDS_IN_SEPARATE_WINDOWS)
    {
      SOUND_PANE(ss) = gtk_vpaned_new();
      gtk_container_set_border_width(GTK_CONTAINER(SOUND_PANE(ss)), 0);
      gtk_container_add(GTK_CONTAINER(MAIN_PANE(ss)), SOUND_PANE(ss));
      if (sound_style(ss) == SOUNDS_IN_NOTEBOOK)
	{
	  SOUND_PANE_BOX(ss) = gtk_notebook_new();
	  gtk_notebook_set_tab_pos(GTK_NOTEBOOK(SOUND_PANE_BOX(ss)), GTK_POS_TOP);
          SG_SIGNAL_CONNECT(SOUND_PANE_BOX(ss), "switch_page", notebook_switch_page, NULL);
	}
      else 
	{
	  if (sound_style(ss) == SOUNDS_HORIZONTAL)
	    SOUND_PANE_BOX(ss) = gtk_hbox_new(false, 0);
	  else SOUND_PANE_BOX(ss) = gtk_vbox_new(false, 0);
	}
      gtk_paned_add1(GTK_PANED(SOUND_PANE(ss)), SOUND_PANE_BOX(ss));
      gtk_widget_show(SOUND_PANE_BOX(ss));
      gtk_widget_show(SOUND_PANE(ss));
    }
  gtk_widget_show(MAIN_PANE(ss));
  gtk_widget_show(MAIN_SHELL(ss));
  
#ifndef SND_AS_WIDGET
#if HAVE_GTK_ADJUSTMENT_GET_UPPER
  MAIN_WINDOW(ss) = gtk_widget_get_window(MAIN_SHELL(ss));
#else
  MAIN_WINDOW(ss) = MAIN_SHELL(ss)->window;
#endif
#else
  MAIN_WINDOW(ss) = gtk_widget_get_parent_window(MAIN_SHELL(ss));
#endif
  
  setup_gcs();
  if (batch) gtk_widget_hide(MAIN_SHELL(ss));
  else gdk_window_resize(WIDGET_TO_WINDOW(MAIN_SHELL(ss)), INITIAL_WINDOW_WIDTH, INITIAL_WINDOW_HEIGHT);
  startup_funcs();
  
#if HAVE_SETJMP_H
#if MUS_TRAP_SEGFAULT
  if (sigsetjmp(envHandleEventsLoop, 1))
    {
      if (!(ss->exiting))
	snd_error_without_format("Caught seg fault (will try to continue):\n");
      else
	{
	  snd_error_without_format("Caught seg fault while trying to exit.\n");
	  exit(0);
	}
    }
#endif
  if (setjmp(top_level_jump))
    {
      if (!(ss->jump_ok))
	snd_error_without_format("Caught top level error (will try to continue):\n");
      else ss->jump_ok = false;
    }
#endif
  
  if (ss->startup_errors)
    {
      post_it("Error in initialization", ss->startup_errors);
      free(ss->startup_errors);
      ss->startup_errors = NULL;
    }

#if HAVE_GTK_3
  set_basic_color(ss->basic_color);
  color_listener(ss->listener_color);

  color_chan_components(ss->zoom_color, COLOR_ZOOM);
  color_chan_components(ss->position_color, COLOR_POSITION);
#endif

#ifndef SND_AS_WIDGET
  set_up_icon();
  gtk_main();
#else
  return(shell);
#endif
}
Ejemplo n.º 5
0
void menu_items_treatment (GtkWidget *Widget, guint Op)
{
  gint CurrentPage, i;

  CurrentPage = gtk_notebook_get_current_page (GTK_NOTEBOOK(MainNotebook));
  switch(Op)
    {
    case NEW                  : new_file ();                   break;
    case OPEN                 : open_file ();                  break;
    case SAVE                 : save_file ();                  break;
    case SAVE_ALL             : save_all ();                   break;
    case SAVE_AS              : save_file_as ();               break;
    case PRINT                : print_buffer ();               break;
    case CLOSE                : close_file ();                 break;
    case CLOSE_ALL            : close_all ();                  break;
    case QUIT                 : quit ();                       break;
    case UNDO                 :
      if (OpenedFilesCnt)
	{
	  proceed_undo ();
	  break;
	 } 
    case REDO                 :
      if (OpenedFilesCnt)
	{
	  proceed_redo ();
	  break;
	}
    case CUT                  :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  gtk_editable_cut_clipboard (GTK_EDITABLE(FPROPS(CurrentPage, Text)));
	  print_msg ("Selection cut to Clipboard...");
	}
      break;
    case COPY                 :
      if (OpenedFilesCnt)
	{
	  gtk_editable_copy_clipboard
	    (GTK_EDITABLE(FPROPS(CurrentPage, Text)));
	  print_msg ("Selection copied to Clipboard...");
	}
	break;
    case PASTE                :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  gtk_editable_paste_clipboard
	    (GTK_EDITABLE(FPROPS(CurrentPage, Text)));
	  print_msg ("Text pasted from Clipboard...");
	}
      break;
    case CLEAR                :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  gtk_editable_delete_text
	    (GTK_EDITABLE(FPROPS(CurrentPage, Text)), 0, -1);
	  print_msg ("Buffer cleared...");
	}
      break;
    case SELECT_ALL           :
      if (OpenedFilesCnt)
	{
	  gtk_editable_select_region
	    (GTK_EDITABLE(FPROPS(CurrentPage, Text)), 0, -1);
	  print_msg ("All Text selected...");
	}
      break;
    case COMPLETE             :
      if (OpenedFilesCnt)
	auto_completion (GTK_TEXT(FPROPS(CurrentPage, Text)));
      break;
    case FIND                 :
      if (OpenedFilesCnt)
	search (FALSE);
      break;
    case REPLACE              :
      if (OpenedFilesCnt)
	search (TRUE);
      break;
    case LINE                 :
      if (OpenedFilesCnt)
	goto_line ();
      break;
    case READONLY             : toggle_readonly ();            break;
    case CONVERTER            : converter ();                  break;
    case COLOR                : color_picker ();               break;
    case INSERT_TIME          : insert_time (CurrentPage);     break;
    case TO_UPPER             :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  change_case (1);
	  print_msg ("Selection converted to upper Case...");
	}
      break;
    case TO_LOWER             :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  change_case (2);
	  print_msg ("Selection converted to Lower Case...");
	}
      break;
    case CAPITALIZE           :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  change_case (3);
	  print_msg ("Selection Capitalized...");
	}
      break; 
    case INVERT_CASE          :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  change_case (4);
	  print_msg ("Case inverted...");
	}
      break;
    case UNIX_DOS             :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  conv_unix_to_dos ();
	}
      break;
    case UNIX_MAC             :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  conv_unix_to_mac ();
	}
      break;
    case DOS_UNIX             :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  conv_dos_to_unix ();
	}
      break;
    case DOS_MAC              :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  conv_dos_to_mac ();
	}
      break;
    case MAC_DOS              :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  conv_mac_to_dos ();
	}
      break;
    case MAC_UNIX             :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  conv_mac_to_unix ();
	}
      break;
    case UNIX_DOS_ALL             :
      convert_all(conv_unix_to_dos);
      break;
    case UNIX_MAC_ALL             :
      convert_all(conv_unix_to_mac);
      break;
    case DOS_UNIX_ALL             :
      convert_all(conv_dos_to_unix);
      break;
    case DOS_MAC_ALL              :
      convert_all(conv_dos_to_mac);
      break;
    case MAC_DOS_ALL              :
      convert_all(conv_mac_to_dos);
      break;
    case MAC_UNIX_ALL             :
      convert_all(conv_mac_to_unix);
      break;
    case FILE_INFO            : file_info (CurrentPage);       break;
    case TOOLBAR              :
      if ((!ToolBarToggleDisplay) && (TOOLBAR_DISPLAY))
	ToolBarToggleDisplay = TRUE;
      else
	{
	  if (TOOLBAR_DISPLAY)
	    {
	      TOOLBAR_DISPLAY = FALSE;
	      hide_toolbar ();
	      print_msg ("Hide Tool Bar...");
	    }
	  else
	    {
	      TOOLBAR_DISPLAY = TRUE;
	      show_toolbar ();
	      if (!ToolBarToggleDisplay) ToolBarToggleDisplay = TRUE;
	      print_msg ("Display Tool Bar...");
	    }
	}
      break;
    case MSGBAR               :
      if ((!MsgBarToggleDisplay) && (MSGBAR_DISPLAY))
	MsgBarToggleDisplay = TRUE;
      else
	{
	  if (MSGBAR_DISPLAY)
	    {
	      MSGBAR_DISPLAY = FALSE;
	      hide_msgbar ();
	    }
	  else
	    {
	      MSGBAR_DISPLAY = TRUE;
	      show_msgbar ();
	      if (!MsgBarToggleDisplay) MsgBarToggleDisplay = TRUE;
	      print_msg ("Display Msg Bar...");
	    }
	}
      break;
    case WORDWRAP        :
     if ((!ToggleWordwrap) && (TOGGLE_WORDWRAP))
	ToggleWordwrap = TRUE;
      else
	{
	  if (TOGGLE_WORDWRAP)
	    {
	      TOGGLE_WORDWRAP = FALSE;
	      for (i = 0; i < OpenedFilesCnt; i++)
		gtk_text_set_word_wrap (GTK_TEXT(FPROPS(CurrentPage, Text)),
					FALSE);
	      print_msg ("Wordwrap disabled...");
	    }
	  else
	    {
	      TOGGLE_WORDWRAP = TRUE;
	      for (i = 0; i < OpenedFilesCnt; i++)
		gtk_text_set_word_wrap (GTK_TEXT(FPROPS(CurrentPage, Text)),
					TRUE);
	      if (!ToggleWordwrap) ToggleWordwrap = TRUE;
	      print_msg ("Wordwrap enabled...");
	    }
	}
      break;
    case TAB_POS_TOP          :
      TAB_POSITION = 1;
      gtk_notebook_set_tab_pos (GTK_NOTEBOOK(MainNotebook), GTK_POS_TOP);
      break;
    case TAB_POS_BOTTOM       :
      TAB_POSITION = 2;
      gtk_notebook_set_tab_pos (GTK_NOTEBOOK(MainNotebook), GTK_POS_BOTTOM);
      break;
    case TAB_POS_LEFT         :
      TAB_POSITION = 3;
      gtk_notebook_set_tab_pos (GTK_NOTEBOOK(MainNotebook), GTK_POS_LEFT);
      break;
    case TAB_POS_RIGHT        :
      TAB_POSITION = 4;
      gtk_notebook_set_tab_pos (GTK_NOTEBOOK(MainNotebook), GTK_POS_RIGHT);  
      break;
    case SCROLLBAR_POS_LEFT   :
      SCROLLBAR_POSITION = 1;
      for (i = 0; i < OpenedFilesCnt; i++)
	gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW
					   (gtk_notebook_get_nth_page
					    (GTK_NOTEBOOK(MainNotebook), i)),
					   GTK_CORNER_TOP_RIGHT);
      break;
    case SCROLLBAR_POS_RIGHT  :
      SCROLLBAR_POSITION = 2;
      for (i = 0; i < OpenedFilesCnt; i++)
	gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW
					   (gtk_notebook_get_nth_page
					    (GTK_NOTEBOOK(MainNotebook), i)),
					   GTK_CORNER_TOP_LEFT);
      break;
    case PREFS                : display_prefs (&Settings);     break;
    case HELP                 :
      print_msg ("No help available yet...");
      break;
    case ABOUT                : about ();                      break;
    }
  (void)Widget; /* avoid the "unused parameter" warning */
}