? .gdb_history ? share Index: configure.in =================================================================== RCS file: /sources/tutka/tutka/configure.in,v retrieving revision 1.28 diff -u -r1.28 configure.in --- configure.in 8 Mar 2006 21:58:48 -0000 1.28 +++ configure.in 14 Dec 2007 16:11:23 -0000 @@ -44,6 +44,25 @@ fi]) AM_CONDITIONAL(HAVE_JACK, test x$have_jack = xyes) +############## +### LASH ### +############## +build_lash="yes" +AC_ARG_ENABLE(lash, + [AS_HELP_STRING(--enable-lash, [Enable LASH session management support (true)])], + [ if test x$enable_lash = xno ; then build_lash=no ; fi ]) +if test "$build_lash" = "yes"; then + PKG_CHECK_MODULES(LASH, lash-1.0 >= 0.5.0, build_lash="yes", build_lash="no") +fi +if test "$build_lash" = "yes"; then + AC_DEFINE(HAVE_LASH, 1, [Has lash.h]) + AC_SUBST(LASH_CFLAGS) + AC_SUBST(LASH_LIBS) +else + AC_MSG_WARN([LASH not found, session support will not be built.]) +fi +AM_CONDITIONAL(HAVE_LASH, [test "$build_lash" = "yes"]) + AC_OUTPUT([ Makefile src/Makefile @@ -53,6 +72,7 @@ Configuration: Install path: ${prefix} - Jack transport support: ${have_jack}" + Jack transport support: ${have_jack} + LASH support: ${build_lash}" echo echo Now type \'make\' to build Tutka. Index: include/editor.h =================================================================== RCS file: /sources/tutka/tutka/include/editor.h,v retrieving revision 1.46 diff -u -r1.46 editor.h --- include/editor.h 8 Mar 2006 21:55:51 -0000 1.46 +++ include/editor.h 14 Dec 2007 16:11:23 -0000 @@ -90,15 +90,9 @@ /* Initializes the editor */ struct editor *editor_open(); /* Opens an existing song or creates new */ -void editor_song_open(struct editor *, char *); +void editor_song_open(struct editor *, const char *); /* Deinitializes the editor */ void editor_close(struct editor *); -/* Remaps the instruments to current set of MIDI interfaces */ -void editor_song_midi_interface_numbers_set(struct editor *); -/* Remaps the instruments to current set of MIDI interfaces */ -void editor_song_midi_interface_names_set(struct editor *); -/* Checks whether there have been changes in MIDI interfaces */ -void editor_midi_status_check(struct editor *); /* Refreshes playseq from section and block from position */ void editor_refresh_playseq_and_block(struct editor *); @@ -188,7 +182,7 @@ void editor_song_instrument_current_name_set(struct editor *, char *); char *editor_song_instrument_current_name_get(struct editor *); char *editor_song_block_name_get(struct editor *, unsigned int); -void editor_song_save(struct editor *, char *); +void editor_song_save(struct editor *, const char *); void editor_song_name_set(struct editor *, char *); void editor_song_transpose(struct editor *, int, int); void editor_song_block_current_transpose(struct editor *, int, int, int, int, int, int); @@ -240,8 +234,6 @@ unsigned int editor_midi_interface_status_set(struct editor *, unsigned int, unsigned int, unsigned int, unsigned int); /* Returns the name of the MIDI interface to use */ char *editor_midi_interface_get(struct editor *, unsigned int, unsigned int); -/* Marks the enabled interfaces as enabled in the preferences */ -void editor_midi_interface_set_from_current(struct editor *); /* Returns the song path from the preferences */ char *editor_song_path_get(struct editor *); /* Returns the message path from the preferences */ Index: include/gui.h =================================================================== RCS file: /sources/tutka/tutka/include/gui.h,v retrieving revision 1.33 diff -u -r1.33 gui.h --- include/gui.h 27 Aug 2006 19:02:15 -0000 1.33 +++ include/gui.h 14 Dec 2007 16:11:23 -0000 @@ -135,7 +135,7 @@ struct gui *gui_open(struct editor *); void gui_close(struct gui *); /* Sets the current filename to the save dialog */ -void gui_set_saveas_filename(struct gui *, char *); +void gui_set_saveas_filename(struct gui *, const char *); /* For setting elements to refresh from the player thread only */ void gui_set_refresh(struct gui *, unsigned int); Index: include/midi.h =================================================================== RCS file: /sources/tutka/tutka/include/midi.h,v retrieving revision 1.32 diff -u -r1.32 midi.h --- include/midi.h 8 Mar 2006 21:55:51 -0000 1.32 +++ include/midi.h 14 Dec 2007 16:11:23 -0000 @@ -61,14 +61,6 @@ struct midi_interface **inputs; /* Number of available MIDI inputs */ unsigned int numinputs; - /* Character string representing successfully subscribed outputs */ - char *outputs_ok; - /* Character string representing successfully subscribed inputs */ - char *inputs_ok; - /* Character string representing failed outputs */ - char *outputs_error; - /* Character string representing failed inputs */ - char *inputs_error; /* Incoming data */ unsigned char *incoming; /* Number of incoming bytes */ @@ -93,15 +85,6 @@ void *data; }; -struct midi_alsa { - /* Client ID */ - int client; - /* Port ID */ - int port; - /* Subscription */ - snd_seq_port_subscribe_t *subs; -}; - struct midi_buffer { /* MIDI outbut buffer */ unsigned char *data; @@ -123,71 +106,91 @@ }; /* Open the MIDI subsystem */ -struct midi *midi_open(struct editor *, char *, char *, char *, char *); +struct midi *midi_open(struct editor *); + /* Close the MIDI subsystem */ void midi_close(struct midi *); -/* Subscribe to a client/port */ -unsigned int midi_subscribe(struct midi *, int, int, unsigned int); -/* Unsubscribe from a client/port */ -unsigned int midi_unsubscribe(struct midi *, int, int, unsigned int); + + + + + /* Allocate a MIDI interface */ struct midi_interface *midi_interface_alloc(unsigned int, char *); + /* Free a MIDI interface */ void midi_interface_free(struct midi_interface *); -/* Get MIDI interface from available interfaces by client and port */ -struct midi_interface *midi_interface_get_by_client_and_port(struct midi *, int, int, unsigned int); -/* Gets an MIDI interface number by name from the available interfaces */ -int midi_interface_number_get_by_name(struct midi *, char *, unsigned int); + /* Gets an MIDI interface name by number from the available interfaces */ char *midi_interface_name_get_by_number(struct midi *, unsigned int, unsigned int); -/* Opens the MIDI interfaces defined in a string */ -void midi_subscribe_all(struct midi *); -/* Unsubscribe all MIDI interfaces and free data */ -void midi_unsubscribe_all(struct midi *midi); -/* Gets the list of available interfaces */ -void midi_interfaces_get(struct midi *, unsigned int); -/* Refreshes the list of available interfaces */ -void midi_interfaces_refresh(struct midi *); + + + /* Sets the current tick */ void midi_set_tick(struct midi_interface *, unsigned int); + /* Stops a note playing on a MIDI channel using requested velocity */ void midi_note_off(struct midi_interface *, unsigned char, unsigned char, unsigned char); + /* Plays a note on a MIDI channel using requested velocity */ void midi_note_on(struct midi_interface *, unsigned char, unsigned char, unsigned char); + /* Sets the aftertouch pressure of a note playing on a MIDI channel */ void midi_aftertouch(struct midi_interface *, unsigned char, unsigned char, unsigned char); + /* Sets the MIDI controller value of a MIDI channel */ void midi_controller(struct midi_interface *, unsigned char, unsigned char, unsigned char); + /* Send a program change on a MIDI channel */ void midi_program_change(struct midi_interface *, unsigned char, unsigned char); + /* Sets the channel pressure of a MIDI channel */ void midi_channel_pressure(struct midi_interface *, unsigned char, unsigned char); + /* Sets the pitch wheel value of a MIDI channel */ void midi_pitch_wheel(struct midi_interface *, unsigned char, unsigned short); + /* Sends a MIDI message */ void midi_write_raw(struct midi_interface *, unsigned char *, unsigned short); + /* Send a clock message */ void midi_clock(struct midi_interface *); + /* Set the tempo (used when exporting) */ void midi_tempo(struct midi_interface *, unsigned int); + + + + /* Receives a MIDI message */ unsigned char *midi_read_raw(struct midi *); + /* Receives a MIDI message */ int midi_read_system_exclusive(struct midi *, struct message *, unsigned int, int); + /* Returns the data written to the MIDI buffer */ unsigned char *midi_get_buffer(struct midi_interface *); + /* Returns the length of data written to the MIDI buffer */ int midi_get_buffer_length(struct midi_interface *); + + + /* Sets the length of a MIDI message */ void message_set_length(struct message *, unsigned int); + /* Sets the auto send flag of a MIDI message */ void message_set_autosend(struct message *, unsigned int); + /* Parses a element in an XML file */ struct message *message_parse(xmlDocPtr, xmlNsPtr, xmlNodePtr); + /* Saves a message to an XML file */ void message_save(struct message *, int, xmlNodePtr); + /* Loads a message from a file */ void message_load_binary(struct message *, char *); + /* Saves a message to a file */ void message_save_binary(struct message *, char *); Index: include/mmd.h =================================================================== RCS file: /sources/tutka/tutka/include/mmd.h,v retrieving revision 1.15 diff -u -r1.15 mmd.h --- include/mmd.h 8 Mar 2006 21:55:51 -0000 1.15 +++ include/mmd.h 14 Dec 2007 16:11:24 -0000 @@ -311,7 +311,7 @@ /* MMD alloc, free and parse functions */ int MMD2_length_get(struct MMD2 *); -struct MMD2 *MMD2_load(char *); +struct MMD2 *MMD2_load(const char *); void MMD2_save(struct MMD2 *, char *); void MMD2_free(struct MMD2 *); void MMD2song_free(struct MMD2song *); Index: include/song.h =================================================================== RCS file: /sources/tutka/tutka/include/song.h,v retrieving revision 1.28 diff -u -r1.28 song.h --- include/song.h 8 Mar 2006 21:55:51 -0000 1.28 +++ include/song.h 14 Dec 2007 16:11:24 -0000 @@ -122,7 +122,7 @@ /* Make sure the instrument exists; add instruments if necessary */ void song_check_instrument(struct song *, int, unsigned short); /* Loads a song from an XML file */ -struct song *song_load(char *); +struct song *song_load(const char *); /* Parses a song element in an XML file */ struct song *song_parse(xmlDocPtr, xmlNsPtr, xmlNodePtr); /* Saves a song to an XML file */ Index: src/Makefile.am =================================================================== RCS file: /sources/tutka/tutka/src/Makefile.am,v retrieving revision 1.20 diff -u -r1.20 Makefile.am --- src/Makefile.am 6 Apr 2005 19:26:08 -0000 1.20 +++ src/Makefile.am 14 Dec 2007 16:11:24 -0000 @@ -35,6 +35,14 @@ tutkaplayer_LDADD += @JACK_LIBS@ endif +if HAVE_LASH +INCLUDES += @LASH_CFLAGS@ +tutka_CFLAGS += -DHAVE_LASH +tutka_LDADD += @LASH_LIBS@ +tutkaplayer_CFLAGS += -DHAVE_LASH +tutkaplayer_LDADD += @LASH_LIBS@ +endif + trackerwidget-marshal.h: trackerwidget-marshal.list ( @GLIB_GENMARSHAL@ --prefix=trackerwidget_marshal trackerwidget-marshal.list --header > trackerwidget-marshal.tmp \ && mv trackerwidget-marshal.tmp trackerwidget-marshal.h ) \ Index: src/callbacks.c =================================================================== RCS file: /sources/tutka/tutka/src/callbacks.c,v retrieving revision 1.124 diff -u -r1.124 callbacks.c --- src/callbacks.c 5 Sep 2006 18:41:02 -0000 1.124 +++ src/callbacks.c 14 Dec 2007 16:11:24 -0000 @@ -87,8 +87,11 @@ void on_menuitem_file_exit_activate(GtkMenuItem * menuitem, gpointer user_data) { struct gui *gui = (struct gui *)user_data; + GtkWidget *window = glade_xml_get_widget(gui->xml, "dialog_quit"); + gtk_window_set_transient_for(GTK_WINDOW(window), GTK_WINDOW(gui->window_main)); + if (!GTK_WIDGET_VISIBLE(window)) gtk_widget_show(window); @@ -1462,9 +1465,7 @@ void gconf_notify_function(GConfClient * client, guint cnxn_id, GConfEntry * entry, gpointer user_data) { - struct gui *gui = (struct gui *)user_data; - - gui_preferences_refresh(gui); +// struct gui *gui = (struct gui *)user_data; } void on_button_message_load_clicked(GtkButton * button, gpointer user_data) @@ -1979,52 +1980,6 @@ gtk_list_store_set(GTK_LIST_STORE(model), &iter, GUI_MESSAGELIST_COLUMN_AUTOSEND, i, -1); } -void on_cell_preferences_midi_interfaces_toggled(GtkCellRendererToggle * cell, gchar * path_string, gpointer user_data) -{ - struct gui *gui = (struct gui *)user_data; - GtkTreeView *treeview; - GtkTreeModel *model; - GtkTreeIter iter; - guint column, direction; - gboolean state; - GValue client = { 0 }, port = { 0 }; - - /* Column number and direction are passed as renderer object data */ - gpointer columnptr = g_object_get_data(G_OBJECT(cell), "column"); - gpointer directionptr = g_object_get_data(G_OBJECT(cell), "direction"); - - column = GPOINTER_TO_UINT(columnptr); - direction = GPOINTER_TO_UINT(directionptr); - - /* Get the iterator */ - if (direction == DIRECTION_OUT) - treeview = GTK_TREE_VIEW(glade_xml_get_widget(gui->xml, "treeview_preferences_midi_interfaces_output")); - else - treeview = GTK_TREE_VIEW(glade_xml_get_widget(gui->xml, "treeview_preferences_midi_interfaces_input")); - model = gtk_tree_view_get_model(treeview); - gtk_tree_model_get_iter_from_string(model, &iter, path_string); - - /* Try changing the state of a device */ - g_object_get(cell, "active", &state, NULL); - if (state) - state = FALSE; - else - state = TRUE; - - gtk_tree_model_get_value(model, &iter, GUI_PREFERENCES_MIDI_INTERFACES_COLUMN_CLIENT, &client); - gtk_tree_model_get_value(model, &iter, GUI_PREFERENCES_MIDI_INTERFACES_COLUMN_PORT, &port); - if (editor_midi_interface_status_set(gui->editor, g_value_get_int(&client), g_value_get_int(&port), direction, state)) - state = TRUE; - else - state = FALSE; - - /* Update the model according to the true status of the device */ - gtk_list_store_set(GTK_LIST_STORE(model), &iter, column, state, -1); - - g_value_unset(&client); - g_value_unset(&port); -} - void on_combobox_instrumentproperties_midiinterface_changed(GtkComboBox * combobox, gpointer user_data) { struct gui *gui = (struct gui *)user_data; Index: src/editor.c =================================================================== RCS file: /sources/tutka/tutka/src/editor.c,v retrieving revision 1.81 diff -u -r1.81 editor.c --- src/editor.c 27 Aug 2006 19:02:23 -0000 1.81 +++ src/editor.c 14 Dec 2007 16:11:24 -0000 @@ -63,13 +63,7 @@ } /* Open the MIDI subsystem */ - editor->midi = midi_open(editor, editor_midi_interface_get(editor, DIRECTION_IN, MIDIINTERFACES_AVAILABLE), editor_midi_interface_get(editor, DIRECTION_OUT, MIDIINTERFACES_AVAILABLE), editor_midi_interface_get(editor, DIRECTION_IN, MIDIINTERFACES_UNAVAILABLE), editor_midi_interface_get(editor, DIRECTION_OUT, MIDIINTERFACES_UNAVAILABLE)); - - /* Some interfaces may have been removed so refresh preferences */ - editor_midi_interface_set_from_current(editor); - - /* Refresh the preferences window */ - gui_preferences_refresh(editor->gui); + editor->midi = midi_open(editor); editor->gconfnotifyid = gconf_client_notify_add(editor->gconfclient, "/apps/tutka", gconf_notify_function, editor->gui, NULL, NULL); @@ -77,7 +71,7 @@ } /* Opens an existing song or creates new */ -void editor_song_open(struct editor *editor, char *filename) +void editor_song_open(struct editor *editor, const char *filename) { nullcheck_void(editor, editor_song_open); @@ -123,11 +117,25 @@ editor->song = song_alloc(); song_check_instrument(editor->song, 0, i); - } else - editor_song_midi_interface_numbers_set(editor); + } /* Store the path in GConf for further use */ path = g_path_get_dirname(filename); + if (path[0] == '.' && (path[1] == 0 || path[1] == '/')) { + gchar *current_dir; + gchar *absolute_path; + + current_dir = g_get_current_dir(); + if (path[1] == 0) { + g_free(path); + path = current_dir; + } else { + absolute_path = g_build_path("/", current_dir, path+2, NULL); + g_free(path); + g_free(current_dir); + path = absolute_path; + } + } path = g_realloc(path, strlen(path) + 2); path[strlen(path) + 1] = 0; path[strlen(path)] = '/'; @@ -216,6 +224,7 @@ free(editor); } +#if 0 /* Remaps the instruments to current set of MIDI interfaces */ void editor_song_midi_interface_numbers_set(struct editor *editor) { @@ -255,42 +264,7 @@ } } } - -/* Checks whether there have been changes in MIDI interfaces */ -void editor_midi_status_check(struct editor *editor) -{ - nullcheck_void(editor, editor_midi_status_check); - - if (!editor->midi->changed) - return; - - /* Store the old MIDI interface names */ - editor_song_midi_interface_names_set(editor); - - /* Make sure the player doesn't try to access the MIDI interfaces until they're refreshed */ - player_lock(editor->player); - - /* Refresh interfaces list */ - midi_interfaces_refresh(editor->midi); - - /* Make sure the MIDI interface numbers are still valid */ - editor_song_midi_interface_numbers_set(editor); - - /* Let the player know about the changes */ - player_midi_changed(editor->player); - - /* The player is free to go */ - player_unlock(editor->player); - - /* Refresh preferences and instrument windows */ - gui_instrument_refresh(editor->gui); - gui_preferences_refresh(editor->gui); - - /* Update the preferences */ - editor_midi_interface_set_from_current(editor); - - editor->midi->changed = 0; -} +#endif /* Changes the current section and refreshes the GUI accordingly */ void editor_set_section(struct editor *editor, int section) @@ -1395,7 +1369,7 @@ } /* Saves the current song */ -void editor_song_save(struct editor *editor, char *filename) +void editor_song_save(struct editor *editor, const char *filename) { nullcheck_void(editor, editor_song_save); @@ -1424,7 +1398,7 @@ smf_save(smf, editor->filename); smf_free(smf); } else { - editor_song_midi_interface_names_set(editor); +// editor_song_midi_interface_names_set(editor); song_save(editor->song, editor->filename); } g_mutex_unlock(editor->songmutex); @@ -1898,42 +1872,7 @@ return gconf_client_get_string(editor->gconfclient, "/apps/tutka/tracker_font", NULL); } -/* Sets the names of the MIDI interfaces to enable separated by , */ -void editor_midi_interface_set(struct editor *editor, char *midi_interface, unsigned int direction, unsigned int mode) -{ - nullcheck_void(editor, editor_midi_interface_set); - - if (mode == MIDIINTERFACES_AVAILABLE) { - if (direction == DIRECTION_IN) - gconf_client_set_string(editor->gconfclient, "/apps/tutka/midi_interfaces/in", midi_interface, NULL); - else - gconf_client_set_string(editor->gconfclient, "/apps/tutka/midi_interfaces/out", midi_interface, NULL); - } else { - if (direction == DIRECTION_IN) - gconf_client_set_string(editor->gconfclient, "/apps/tutka/midi_interfaces/unavailable_in", midi_interface, NULL); - else - gconf_client_set_string(editor->gconfclient, "/apps/tutka/midi_interfaces/unavailable_out", midi_interface, NULL); - } -} - -/* Returns the names of the MIDI interfaces to enable separated by , */ -char *editor_midi_interface_get(struct editor *editor, unsigned int direction, unsigned int mode) -{ - nullcheck_pointer(editor, editor_midi_interface_get); - - if (mode == MIDIINTERFACES_AVAILABLE) { - if (direction == DIRECTION_IN) - return gconf_client_get_string(editor->gconfclient, "/apps/tutka/midi_interfaces/in", NULL); - else - return gconf_client_get_string(editor->gconfclient, "/apps/tutka/midi_interfaces/out", NULL); - } else { - if (direction == DIRECTION_IN) - return gconf_client_get_string(editor->gconfclient, "/apps/tutka/midi_interfaces/unavailable_in", NULL); - else - return gconf_client_get_string(editor->gconfclient, "/apps/tutka/midi_interfaces/unavailable_out", NULL); - } -} - +#if 0 /* Removes the last character from a string if the string is not null */ static char *string_shorten(char *in) { @@ -1948,52 +1887,7 @@ memcpy(out, in, l - 1); return out; } - -/* Marks the enabled interfaces as enabled in the preferences */ -void editor_midi_interface_set_from_current(struct editor *editor) -{ - nullcheck_void(editor, editor_midi_interface_preferences_refresh); - - /* Set the MIDI interfaces */ - char *outputs_ok = string_shorten(editor->midi->outputs_ok); - char *inputs_ok = string_shorten(editor->midi->inputs_ok); - char *outputs_error = string_shorten(editor->midi->outputs_error); - char *inputs_error = string_shorten(editor->midi->inputs_error); - editor_midi_interface_set(editor, inputs_ok, DIRECTION_IN, MIDIINTERFACES_AVAILABLE); - editor_midi_interface_set(editor, outputs_ok, DIRECTION_OUT, MIDIINTERFACES_AVAILABLE); - editor_midi_interface_set(editor, inputs_error, DIRECTION_IN, MIDIINTERFACES_UNAVAILABLE); - editor_midi_interface_set(editor, outputs_error, DIRECTION_OUT, MIDIINTERFACES_UNAVAILABLE); -} - -/* Enables or disables a MIDI interface by client and port */ -unsigned int editor_midi_interface_status_set(struct editor *editor, unsigned int client, unsigned int port, unsigned int direction, unsigned int enabled) -{ - nullcheck_int(editor, editor_midi_interface_status_set); - - unsigned int result; - - if (enabled) - /* Subscribe */ - result = midi_subscribe(editor->midi, client, port, direction); - else { - /* Store the old MIDI interface names */ - editor_song_midi_interface_names_set(editor); - - /* Unsubscribe */ - result = 1 - midi_unsubscribe(editor->midi, client, port, direction); - - /* Make sure the MIDI interface numbers are still valid */ - editor_song_midi_interface_numbers_set(editor); - } - - /* Refresh the instrument window */ - gui_instrument_refresh(editor->gui); - - /* Update the preferences */ - editor_midi_interface_set_from_current(editor); - - return result; -} +#endif /* Returns the song path from the preferences */ char *editor_song_path_get(struct editor *editor) Index: src/gui.c =================================================================== RCS file: /sources/tutka/tutka/src/gui.c,v retrieving revision 1.96 diff -u -r1.96 gui.c --- src/gui.c 27 Aug 2006 19:02:23 -0000 1.96 +++ src/gui.c 14 Dec 2007 16:11:24 -0000 @@ -227,7 +227,6 @@ g_object_set(renderer, "activatable", TRUE, NULL); g_object_set_data(G_OBJECT(renderer), "column", GUINT_TO_POINTER(GUI_PREFERENCES_MIDI_INTERFACES_COLUMN_ENABLED)); g_object_set_data(G_OBJECT(renderer), "direction", GUINT_TO_POINTER(DIRECTION_OUT)); - g_signal_connect(renderer, "toggled", G_CALLBACK(on_cell_preferences_midi_interfaces_toggled), gui); gtk_tree_view_append_column(treeview, new_column("Enabled", renderer, "active", GUI_PREFERENCES_MIDI_INTERFACES_COLUMN_ENABLED, NULL)); store = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_INT); @@ -242,7 +241,6 @@ g_object_set(renderer, "activatable", TRUE, NULL); g_object_set_data(G_OBJECT(renderer), "column", GUINT_TO_POINTER(GUI_PREFERENCES_MIDI_INTERFACES_COLUMN_ENABLED)); g_object_set_data(G_OBJECT(renderer), "direction", GUINT_TO_POINTER(DIRECTION_IN)); - g_signal_connect(renderer, "toggled", G_CALLBACK(on_cell_preferences_midi_interfaces_toggled), gui); gtk_tree_view_append_column(treeview, new_column("Enabled", renderer, "active", GUI_PREFERENCES_MIDI_INTERFACES_COLUMN_ENABLED, NULL)); /* Set the keyboard octave */ @@ -308,7 +306,7 @@ } /* Sets the current filename to the save dialog */ -void gui_set_saveas_filename(struct gui *gui, char *filename) +void gui_set_saveas_filename(struct gui *gui, const char *filename) { /* Set default path in save as dialog */ if (filename != NULL) { @@ -316,6 +314,21 @@ path = g_path_get_dirname(filename); name = g_path_get_basename(filename); + if (path[0] == '.' && (path[1] == 0 || path[1] == '/')) { + gchar *current_dir; + gchar *absolute_path; + + current_dir = g_get_current_dir(); + if (path[1] == 0) { + g_free(path); + path = current_dir; + } else { + absolute_path = g_build_path("/", current_dir, path+2, NULL); + g_free(path); + g_free(current_dir); + path = absolute_path; + } + } gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(glade_xml_get_widget(gui->xml, "filechooserdialog_file_saveas")), path); gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(glade_xml_get_widget(gui->xml, "filechooserdialog_file_saveas")), name); g_free(path); @@ -602,18 +615,12 @@ selected = n; n++; } else { - struct midi_alsa *alsa = (struct midi_alsa *)gui->editor->midi->outputs[i]->data; - if (alsa->subs != NULL) { - if (gui->editor->midi->outputs[i]->name != NULL) - snprintf(midiinterface, 256, "%s (%d:%d)", gui->editor->midi->outputs[i]->name, alsa->client, alsa->port); - else - snprintf(midiinterface, 256, "Unknown (%d:%d)", alsa->client, alsa->port); - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, 0, midiinterface, 1, i, -1); - if (i == current) - selected = n; - n++; - } + snprintf(midiinterface, 256, "%s", gui->editor->midi->outputs[i]->name); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, 0, midiinterface, 1, i, -1); + if (i == current) + selected = n; + n++; } } gtk_combo_box_set_active(combobox, selected); @@ -1029,89 +1036,6 @@ gtk_widget_show_all(table); } -void gui_preferences_refresh(struct gui *gui) -{ - GtkTreeView *treeview_output = GTK_TREE_VIEW(glade_xml_get_widget(gui->xml, "treeview_preferences_midi_interfaces_output")); - GtkTreeView *treeview_input = GTK_TREE_VIEW(glade_xml_get_widget(gui->xml, "treeview_preferences_midi_interfaces_input")); - GtkComboBox *combobox = GTK_COMBO_BOX(glade_xml_get_widget(gui->xml, "combobox_preferences_scheduling_mode")); - int i; - - /* Refresh the preferences window widgets */ - g_signal_handlers_block_by_func(treeview_output, on_cell_preferences_midi_interfaces_toggled, gui); - g_signal_handlers_block_by_func(treeview_input, on_cell_preferences_midi_interfaces_toggled, gui); - g_signal_handlers_block_by_func(combobox, on_combobox_preferences_scheduling_mode_changed, gui); - - /* Recreate the interfaces lists */ - GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview_output)); - gtk_list_store_clear(store); - for (i = 1; i < gui->editor->midi->numoutputs; i++) { - GtkTreeIter iter; - char name[256]; - gboolean enabled = FALSE; - int client = 0, port = 0; - - if (gui->editor->midi->outputs[i]->type == MIDI_ALSA) { - struct midi_alsa *alsa = (struct midi_alsa *)gui->editor->midi->outputs[i]->data; - - if (alsa->subs != NULL) - enabled = TRUE; - - client = alsa->client; - port = alsa->port; - - if (gui->editor->midi->outputs[i]->name != NULL) - snprintf(name, 256, "%s (%d:%d)", gui->editor->midi->outputs[i]->name, client, port); - else - snprintf(name, 256, "Unknown (%d:%d)", client, port); - } else { - if (gui->editor->midi->outputs[i]->name != NULL) - snprintf(name, 256, "%s", gui->editor->midi->outputs[i]->name); - else - snprintf(name, 256, "Unknown"); - } - - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, GUI_PREFERENCES_MIDI_INTERFACES_COLUMN_NAME, name, GUI_PREFERENCES_MIDI_INTERFACES_COLUMN_ENABLED, enabled, GUI_PREFERENCES_MIDI_INTERFACES_COLUMN_CLIENT, client, GUI_PREFERENCES_MIDI_INTERFACES_COLUMN_PORT, port, -1); - } - - store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview_input)); - gtk_list_store_clear(store); - for (i = 0; i < gui->editor->midi->numinputs; i++) { - GtkTreeIter iter; - char name[256]; - gboolean enabled = FALSE; - int client = 0, port = 0; - - if (gui->editor->midi->inputs[i]->type == MIDI_ALSA) { - struct midi_alsa *alsa = (struct midi_alsa *)gui->editor->midi->inputs[i]->data; - - if (alsa->subs != NULL) - enabled = TRUE; - - client = alsa->client; - port = alsa->port; - - if (gui->editor->midi->inputs[i]->name != NULL) - snprintf(name, 256, "%s (%d:%d)", gui->editor->midi->inputs[i]->name, client, port); - else - snprintf(name, 256, "Unknown (%d:%d)", client, port); - } else { - if (gui->editor->midi->inputs[i]->name != NULL) - snprintf(name, 256, "%s", gui->editor->midi->inputs[i]->name); - else - snprintf(name, 256, "Unknown"); - } - - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, GUI_PREFERENCES_MIDI_INTERFACES_COLUMN_NAME, name, GUI_PREFERENCES_MIDI_INTERFACES_COLUMN_ENABLED, enabled, GUI_PREFERENCES_MIDI_INTERFACES_COLUMN_CLIENT, client, GUI_PREFERENCES_MIDI_INTERFACES_COLUMN_PORT, port, -1); - } - - gtk_combo_box_set_active(combobox, editor_scheduler_get(gui->editor) - SCHED_RTC); - g_signal_handlers_unblock_by_func(treeview_output, on_cell_preferences_midi_interfaces_toggled, gui); - g_signal_handlers_unblock_by_func(treeview_input, on_cell_preferences_midi_interfaces_toggled, gui); - g_signal_handlers_unblock_by_func(combobox, on_combobox_preferences_scheduling_mode_changed, gui); -} - void gui_receive_refresh(struct gui *gui, int bytes, int total) { GtkProgressBar *pbar = GTK_PROGRESS_BAR(glade_xml_get_widget(gui->xml, "progressbar_receive")); Index: src/main.c =================================================================== RCS file: /sources/tutka/tutka/src/main.c,v retrieving revision 1.31 diff -u -r1.31 main.c --- src/main.c 8 Mar 2006 21:55:51 -0000 1.31 +++ src/main.c 14 Dec 2007 16:11:24 -0000 @@ -27,6 +27,11 @@ #include #include #include + +#ifdef HAVE_LASH +# include +#endif + #include "editor.h" #include "gui.h" #include "callbacks.h" @@ -35,6 +40,56 @@ extern gboolean gui_quit; char *nullcheck_error_string = "%s() called with null %s\n"; +#ifdef HAVE_LASH +/* filename used to store tutka project withion current lash project directory */ +#define LASH_TUTKA_FILENAME "tutka.xml" + +lash_client_t *lash_client_ptr; + +/* Check for new LASH events */ +void lash_check_events(struct editor *editor) +{ + lash_event_t *lash_event_ptr; + gchar *filename; + const char * lash_dir; + + while ((lash_event_ptr = lash_get_event(lash_client_ptr)) != NULL) + { + switch (lash_event_get_type(lash_event_ptr)) + { + case LASH_Save_File: + lash_dir = lash_event_get_string(lash_event_ptr); + printf("LASH asked Tutka to save data in directory %s\n", lash_dir); + filename = g_strconcat(lash_dir, "/", LASH_TUTKA_FILENAME); + editor_song_save(editor, filename); + g_free(filename); + lash_send_event(lash_client_ptr, lash_event_ptr); + break; + + case LASH_Restore_File: + lash_dir = lash_event_get_string(lash_event_ptr); + printf("LASH asked Tutka to restore data from directory %s\n", lash_dir); + filename = g_strconcat(lash_dir, "/", LASH_TUTKA_FILENAME); + editor_song_open(editor, filename); + g_free(filename); + lash_event_destroy(lash_event_ptr); + break; + + case LASH_Quit: + printf("LASH asked Tutka to quit.\n"); + lash_event_destroy(lash_event_ptr); + gtk_main_quit(); + break; + + default: + printf("Got unhandled LASH event\n"); + lash_event_destroy(lash_event_ptr); + } + } +} + +#endif /* LASH */ + int main(int argc, char *argv[]) { struct editor *editor = NULL; @@ -48,6 +103,24 @@ return -1; } +#ifdef HAVE_LASH + lash_client_ptr = lash_init( + lash_extract_args(&argc, &argv), + PACKAGE_NAME, + LASH_Config_File, + LASH_PROTOCOL_VERSION); + if (lash_client_ptr != NULL) + { + lash_event_t *lash_event_ptr; + + printf("Successfully connected to the LASH daemon\n"); + + lash_event_ptr = lash_event_new_with_type(LASH_Client_Name); + lash_event_set_string(lash_event_ptr, PACKAGE_NAME); + lash_send_event(lash_client_ptr, lash_event_ptr); + } +#endif + gnome_init("Tutka", VERSION, argc, argv); glade_gnome_init(); @@ -60,6 +133,10 @@ else editor_song_open(editor, NULL); +#ifdef HAVE_LASH + lash_alsa_client_id(lash_client_ptr, editor->midi->client); +#endif + /* Main loop */ gdk_threads_enter(); while (!gui_quit) { @@ -87,12 +164,13 @@ } } - /* Check whether there have been changes in MIDI interfaces */ - editor_midi_status_check(editor); - /* Refresh the GUI */ gui_refresh(editor->gui); +#ifdef HAVE_LASH + lash_check_events(editor); +#endif + /* Sleep for a while */ nanosleep(&nobusywait, 0); } Index: src/midi.c =================================================================== RCS file: /sources/tutka/tutka/src/midi.c,v retrieving revision 1.57 diff -u -r1.57 midi.c --- src/midi.c 8 Mar 2006 21:55:51 -0000 1.57 +++ src/midi.c 14 Dec 2007 16:11:24 -0000 @@ -24,16 +24,19 @@ #include #include #include + #include "tutka.h" #include "midi.h" #include "player.h" +#if 0 static char *string_remove_string(char *from, char *toremove); static char *string_append_char(char *to, char append); static char *string_append_string(char *to, char *append); +#endif /* Open the MIDI subsystem */ -struct midi *midi_open(struct editor *editor, char *in, char *out, char *unavailablein, char *unavailableout) +struct midi *midi_open(struct editor *editor) { struct midi *midi = (struct midi *)calloc(1, sizeof(struct midi)); snd_seq_addr_t sender, dest; @@ -77,15 +80,17 @@ snd_midi_event_no_status(midi->encoder, 1); snd_midi_event_no_status(midi->decoder, 1); - /* Set requested interfaces */ - midi->outputs_ok = out; - midi->inputs_ok = in; - midi->outputs_error = unavailableout; - midi->inputs_error = unavailablein; + /* Add a null MIDI interface */ + midi->numoutputs = 1; + midi->outputs = (struct midi_interface **)calloc(1, sizeof(struct midi_interface *)); + + /* Add a ALSA MIDI interface */ + midi->outputs[0] = calloc(1, sizeof(struct midi_interface)); + midi->outputs[0]->midi = midi; + midi->outputs[0]->type = MIDI_ALSA; + midi->outputs[0]->data = NULL; + midi->outputs[0]->name = strdup("ALSA Output"); - /* Get MIDI interfaces */ - midi_interfaces_refresh(midi); - return midi; } @@ -108,7 +113,7 @@ snd_seq_unsubscribe_port(midi->seq, subs); /* Unsubscribe and free all interfaces */ - midi_unsubscribe_all(midi); + //midi_unsubscribe_all(midi); /* Free MIDI event encoder and decoder */ if (midi->encoder != NULL) @@ -127,6 +132,7 @@ free(midi); } +#if 0 /* Subscribe to a client/port */ unsigned int midi_subscribe(struct midi *midi, int client, int port, unsigned int direction) { @@ -227,6 +233,7 @@ } return 0; } +#endif /* Allocate a MIDI interface */ struct midi_interface *midi_interface_alloc(unsigned int type, char *name) @@ -235,9 +242,6 @@ midi->type = type; switch (type) { - case MIDI_ALSA: - midi->data = calloc(1, sizeof(struct midi_alsa)); - break; case MIDI_BUFFER: midi->data = calloc(1, sizeof(struct midi_buffer)); break; @@ -260,75 +264,6 @@ free(midi->data); } -/* Get MIDI interface from available interfaces by client and port */ -struct midi_interface *midi_interface_get_by_client_and_port(struct midi *midi, int client, int port, unsigned int direction) -{ - nullcheck_pointer(midi, midi_interface_get_by_client_and_port); - - struct midi_interface **interfaces; - int i, n; - - if (direction == DIRECTION_OUT) { - interfaces = midi->outputs; - n = midi->numoutputs; - } else { - interfaces = midi->inputs; - n = midi->numinputs; - } - - for (i = 0; i < n; i++) { - if (interfaces[i]->type == MIDI_ALSA) { - struct midi_alsa *alsa = (struct midi_alsa *)interfaces[i]->data; - if (alsa->client == client && alsa->port == port) - return interfaces[i]; - } - } - - return NULL; -} - -/* Gets an MIDI interface number by name from the subscribed interfaces */ -int midi_interface_number_get_by_name(struct midi *midi, char *name, unsigned int direction) -{ - nullcheck_int(midi, midi_interface_get_by_name); - - /* Use the null interface if no name specified */ - if (name == NULL) - return 0; - - int i, n, client = 0, port = 0; - struct midi_interface **interfaces; - char *c = name; - - while (*c != 0 && *c != ':') - c++; - if (*c == ':') { - *c++ = 0; - port = atoi(c); - } - client = atoi(name); - - if (direction == DIRECTION_OUT) { - n = midi->numoutputs; - interfaces = midi->outputs; - } else { - n = midi->numinputs; - interfaces = midi->inputs; - } - - for (i = 1; i < n; i++) { - struct midi_interface *iface = interfaces[i]; - if (iface->type == MIDI_ALSA) { - struct midi_alsa *alsa = (struct midi_alsa *)iface->data; - if (alsa->client == client && alsa->port == port && alsa->subs != NULL) - return i; - } - } - - /* If no interface is found use the null interface */ - return 0; -} - /* Gets an MIDI interface name by number from the available interfaces */ char *midi_interface_name_get_by_number(struct midi *midi, unsigned int number, unsigned int direction) { @@ -342,14 +277,12 @@ iface = midi->inputs[number]; if (iface->type == MIDI_ALSA) { - struct midi_alsa *alsa = (struct midi_alsa *)iface->data; - char name[256]; - snprintf(name, 256, "%d:%d", alsa->client, alsa->port); - return strdup(name); + return strdup(iface->name); } else return NULL; } +#if 0 /* Opens the MIDI interfaces defined in the strings */ void midi_subscribe_all(struct midi *midi) { @@ -477,81 +410,7 @@ midi->inputs = NULL; } -/* Gets the list of available interfaces */ -void midi_interfaces_get(struct midi *midi, unsigned int direction) -{ - nullcheck_void(midi, midi_interfaces_get); - - snd_seq_client_info_t *cinfo; - snd_seq_port_info_t *pinfo; - int bits; - - /* Set permissions to check based on direction */ - if (direction == DIRECTION_OUT) { - bits = SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE; - } else { - bits = SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ; - } - - snd_seq_client_info_alloca(&cinfo); - snd_seq_port_info_alloca(&pinfo); - snd_seq_client_info_set_client(cinfo, SND_SEQ_CLIENT_SYSTEM); - while (snd_seq_query_next_client(midi->seq, cinfo) >= 0) { - /* Reset query info */ - snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); - snd_seq_port_info_set_port(pinfo, -1); - while (snd_seq_query_next_port(midi->seq, pinfo) >= 0) { - int client = snd_seq_port_info_get_client(pinfo); - int port = snd_seq_port_info_get_port(pinfo); - /* Check whether the capabilities match the current direction */ - if (snd_seq_port_info_get_capability(pinfo) & bits && !(client == midi->client && port == midi->port)) { - /* Create an interface structure for the port */ - struct midi_interface *iface; - struct midi_alsa *alsa; - alsa = calloc(1, sizeof(struct midi_alsa)); - alsa->client = client; - alsa->port = port; - iface = calloc(1, sizeof(struct midi_interface)); - iface->midi = midi; - iface->type = MIDI_ALSA; - iface->data = alsa; - iface->name = strdup(snd_seq_port_info_get_name(pinfo)); - - /* Append the interface to the interface array */ - if (direction == DIRECTION_OUT) { - midi->numoutputs++; - midi->outputs = (struct midi_interface **)realloc(midi->outputs, midi->numoutputs * sizeof(struct midi_interface *)); - midi->outputs[midi->numoutputs - 1] = iface; - } else { - midi->numinputs++; - midi->inputs = (struct midi_interface **)realloc(midi->inputs, midi->numinputs * sizeof(struct midi_interface *)); - midi->inputs[midi->numinputs - 1] = iface; - } - } - } - } -} - -/* Refreshes the list of available interfaces */ -void midi_interfaces_refresh(struct midi *midi) -{ - nullcheck_void(midi, midi_interfaces_refresh); - - /* Unsubscribe all */ - midi_unsubscribe_all(midi); - - /* Add a null MIDI interface */ - midi->numoutputs = 1; - midi->outputs = (struct midi_interface **)calloc(1, sizeof(struct midi_interface *)); - midi->outputs[0] = midi_interface_alloc(MIDI_NULL, "No output"); - - /* Refresh lists */ - midi_interfaces_get(midi, DIRECTION_OUT); - midi_interfaces_get(midi, DIRECTION_IN); - - /* Resubscribe */ - midi_subscribe_all(midi); -} +#endif /* Sets the current tick */ void midi_set_tick(struct midi_interface *midi, unsigned int tick) @@ -661,14 +520,13 @@ switch (midi->type) { case MIDI_ALSA: { - struct midi_alsa *alsa = midi->data; int l = 0; /* Create event */ snd_seq_event_t ev; snd_seq_ev_clear(&ev); snd_seq_ev_set_source(&ev, midi->midi->port); - snd_seq_ev_set_dest(&ev, alsa->client, alsa->port); + snd_seq_ev_set_subs(&ev); snd_seq_ev_set_direct(&ev); /* The encoder may send the data in multiple packets */ while (l < length) { @@ -1148,6 +1006,7 @@ } /* Helper functions */ +#if 0 static char *string_remove_string(char *from, char *toremove) { int fl = strlen(from) + 1; @@ -1200,3 +1059,4 @@ return to; } +#endif Index: src/mmd.c =================================================================== RCS file: /sources/tutka/tutka/src/mmd.c,v retrieving revision 1.22 diff -u -r1.22 mmd.c --- src/mmd.c 8 Mar 2006 21:55:51 -0000 1.22 +++ src/mmd.c 14 Dec 2007 16:11:25 -0000 @@ -150,7 +150,7 @@ } /* Loads an MMD2 file and returns a pointer to its MMD0 structure */ -struct MMD2 *MMD2_load(char *filename) +struct MMD2 *MMD2_load(const char *filename) { nullcheck_pointer(filename, MMD2_load); Index: src/song.c =================================================================== RCS file: /sources/tutka/tutka/src/song.c,v retrieving revision 1.52 diff -u -r1.52 song.c --- src/song.c 8 Mar 2006 21:55:51 -0000 1.52 +++ src/song.c 14 Dec 2007 16:11:25 -0000 @@ -481,7 +481,7 @@ } /* Loads a song from an XML file */ -struct song *song_load(char *filename) +struct song *song_load(const char *filename) { xmlDocPtr doc; xmlNodePtr cur; Index: src/trackerwidget.c =================================================================== RCS file: /sources/tutka/tutka/src/trackerwidget.c,v retrieving revision 1.25 diff -u -r1.25 trackerwidget.c --- src/trackerwidget.c 8 Mar 2006 21:55:51 -0000 1.25 +++ src/trackerwidget.c 14 Dec 2007 16:11:25 -0000 @@ -691,7 +691,7 @@ if (t->disp_numchans > t->num_channels) t->disp_numchans = t->num_channels; - t->disp_startx = (u - t->disp_numchans * t->disp_chanwidth) / 2 + line_numbers_space + 5; + t->disp_startx = /*(u - t->disp_numchans * t->disp_chanwidth) / 2 + */line_numbers_space + 5; adjust_xpanning(t); if (t->curpattern) { Index: src/tutkaplayer.c =================================================================== RCS file: /sources/tutka/tutka/src/tutkaplayer.c,v retrieving revision 1.26 diff -u -r1.26 tutkaplayer.c --- src/tutkaplayer.c 8 Mar 2006 21:55:51 -0000 1.26 +++ src/tutkaplayer.c 14 Dec 2007 16:11:25 -0000 @@ -39,7 +39,7 @@ char *nullcheck_error_string = "%s() called with null %s\n"; /* Not used */ -struct MMD2 *MMD2_load(char *filename) +struct MMD2 *MMD2_load(const char *filename) { return NULL; } @@ -171,14 +171,14 @@ int i, j; /* Open MIDI */ - editor->midi = midi_open(editor, gconf_client_get_string(editor->gconfclient, "/apps/tutka/midi_interfaces/in", NULL), gconf_client_get_string(editor->gconfclient, "/apps/tutka/midi_interfaces/out", NULL), gconf_client_get_string(editor->gconfclient, "/apps/tutka/midi_interfaces/unavailable_in", NULL), gconf_client_get_string(editor->gconfclient, "/apps/tutka/midiinterfaces/unavailable_out", NULL)); + editor->midi = midi_open(editor); /* Remap the instruments to current set of MIDI interfaces */ for (i = 0; i < editor->song->numinstruments; i++) { struct instrument *instrument = editor->song->instruments[i]; for (j = 0; j < instrument->numoutputs; j++) { struct instrument_output *output = instrument->outputs[j]; - output->midiinterface = midi_interface_number_get_by_name(editor->midi, output->midiinterfacename, DIRECTION_OUT); + output->midiinterface = 0; } }