| 1 | package Audio::GtkGramofile::GUI; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 0 | ▶ | use Gtk2; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 7 | use Audio::GtkGramofile::Settings; | ||
| 8 | |||
| 9 | use vars qw($VERSION); | ||
| 10 | $VERSION = do { my @r = (q$Revision: 1.6 $ =~ /\d+/g); shift @r; sprintf("0.%04d",@r) }; # must be all one line, for MakeMaker | ||
| 11 | |||
| 12 | use constant ROW_HEIGHT => 4; | ||
| 13 | use constant APP_WIDTH => 690; | ||
| 14 | use constant APP_HEIGHT => 800; | ||
| 15 | use constant SCREEN_OFF => 50; | ||
| 16 | |||
| 17 | sub new { | ||
| 18 | my $proto = shift; | ||
| 19 | my $class = ref($proto) || $proto; | ||
| 20 | |||
| 21 | my $self = {}; | ||
| 22 | bless $self, $class; | ||
| 23 | |||
| 24 | $self->{finished} = \&on_setting_finished; | ||
| 25 | $self->{changed} = \&on_setting_changed; | ||
| 26 | return $self; | ||
| 27 | } | ||
| 28 | |||
| 29 | sub set_gtkgramofile { | ||
| 30 | my $self = shift; | ||
| 31 | my $gtkgramofile = shift; | ||
| 32 | |||
| 33 | $self->{gtkgramofile} = $gtkgramofile; | ||
| 34 | } | ||
| 35 | |||
| 36 | sub create_stock_buttons { | ||
| 37 | my $self = shift; | ||
| 38 | |||
| 39 | my $factory = Gtk2::IconFactory->new; | ||
| 40 | $factory->add_default; | ||
| 41 | my $style = Gtk2::Style->new; | ||
| 42 | my @items = ( | ||
| 43 | { stock_id => "ar_mixer", label => "Mixer", icon => 'gtk-execute' }, | ||
| 44 | { stock_id => "ar_play", label => "Play", icon => 'gtk-cdrom' }, | ||
| 45 | { stock_id => "ar_record", label => "Record", icon => 'gtk-ok' }, | ||
| 46 | { stock_id => "ar_save", label => "Save Settings", icon => 'gtk-save' }, | ||
| 47 | { stock_id => "ar_cancel", label => "Close Window", icon => 'gtk-cancel' }, | ||
| 48 | { stock_id => "ar_find", label => "Browse", icon => 'gtk-find' }, | ||
| 49 | { stock_id => "ar_quit", label => "Quit", icon => 'gtk-quit' }, | ||
| 50 | { stock_id => "ar_start", label => "Start", icon => 'gtk-convert' }, | ||
| 51 | { stock_id => "ar_properties", label => "Set", icon => 'gtk-properties' }, | ||
| 52 | { stock_id => "ar_stop", label => "Stop", icon => 'gtk-stop' } | ||
| 53 | ); | ||
| 54 | Gtk2::Stock->add(@items); | ||
| 55 | foreach (@items) { | ||
| 56 | $factory->add($_->{'stock_id'}, $style->lookup_icon_set($_->{'icon'})); | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | sub check_button { | ||
| 61 | my $self = shift; | ||
| 62 | my $table = shift; | ||
| 63 | my $button_text = shift; | ||
| 64 | my $checkxstart = shift; | ||
| 65 | my $checkxend = shift; | ||
| 66 | my $ystart = shift; | ||
| 67 | my $yend = shift; | ||
| 68 | |||
| 69 | my $check = Gtk2::CheckButton->new($button_text); | ||
| 70 | $check->show; | ||
| 71 | $self->{$table}->attach($check, $checkxstart, $checkxend, $ystart, $yend, ['fill'], [], 2, 2); | ||
| 72 | $check; | ||
| 73 | } | ||
| 74 | |||
| 75 | sub label_and_entry { | ||
| 76 | my $self = shift; | ||
| 77 | my $table = shift; | ||
| 78 | my $label_text = shift; | ||
| 79 | my $labelxstart = shift; | ||
| 80 | my $labelxend = shift; | ||
| 81 | my $entryxstart = shift; | ||
| 82 | my $entryxend = shift; | ||
| 83 | my $ystart = shift; | ||
| 84 | my $yend = shift; | ||
| 85 | |||
| 86 | my $label = Gtk2::Label->new($label_text); | ||
| 87 | $label->set_alignment(0,0.5); | ||
| 88 | $self->{$table}->attach($label, $labelxstart, $labelxend, $ystart, $yend, ['fill'], [], 2, 2); | ||
| 89 | $label->show; | ||
| 90 | |||
| 91 | my $entry = Gtk2::Entry->new; | ||
| 92 | $entry->show; | ||
| 93 | $entry->set_size_request(10, -1); | ||
| 94 | $self->{$table}->attach($entry, $entryxstart, $entryxend, $ystart, $yend, ['fill'], [], 2, 2); | ||
| 95 | $entry; | ||
| 96 | } | ||
| 97 | |||
| 98 | sub label_and_entry_and_button { | ||
| 99 | my $self = shift; | ||
| 100 | my $table = shift; | ||
| 101 | my $label_text = shift; | ||
| 102 | my $labelxstart = shift; | ||
| 103 | my $labelxend = shift; | ||
| 104 | my $entryxstart = shift; | ||
| 105 | my $entryxend = shift; | ||
| 106 | my $buttonxstart = shift; | ||
| 107 | my $buttonxend = shift; | ||
| 108 | my $ystart = shift; | ||
| 109 | my $yend = shift; | ||
| 110 | |||
| 111 | my $entry = $self->label_and_entry($table, $label_text, $labelxstart, $labelxend, $entryxstart, | ||
| 112 | $entryxend, $ystart, $yend); | ||
| 113 | my $button = Gtk2::Button->new_from_stock('ar_find'); | ||
| 114 | $button->show; | ||
| 115 | $button->set_size_request(10, -1); | ||
| 116 | $self->{$table}->attach($button, $buttonxstart, $buttonxend, $ystart, $yend, ['fill'], [], 2, 2); | ||
| 117 | ($entry, $button); | ||
| 118 | } | ||
| 119 | |||
| 120 | sub separator { | ||
| 121 | my $self = shift; | ||
| 122 | my $table = shift; | ||
| 123 | my $xstart = shift; | ||
| 124 | my $xend = shift; | ||
| 125 | my $ystart = shift; | ||
| 126 | my $yend = shift; | ||
| 127 | |||
| 128 | my $separator = Gtk2::HSeparator->new; | ||
| 129 | $separator->show; | ||
| 130 | $self->{$table}->attach($separator, $xstart, $xend, $ystart, $yend, ['fill'], [], 2, 2); | ||
| 131 | } | ||
| 132 | |||
| 133 | sub label_and_spin { | ||
| 134 | my $self = shift; | ||
| 135 | my $table = shift; | ||
| 136 | my $label_text = shift; | ||
| 137 | my $labelxstart = shift; | ||
| 138 | my $labelxend = shift; | ||
| 139 | my $spinxstart = shift; | ||
| 140 | my $spinxend = shift; | ||
| 141 | my $ystart = shift; | ||
| 142 | my $yend = shift; | ||
| 143 | my $adj1 = shift; | ||
| 144 | my $adj2 = shift; | ||
| 145 | |||
| 146 | my $label = Gtk2::Label->new($label_text); | ||
| 147 | $label->set_alignment(0,0.5); | ||
| 148 | $self->{$table}->attach_defaults($label, $labelxstart, $labelxend, $ystart, $yend); | ||
| 149 | $label->show; | ||
| 150 | |||
| 151 | my $adjust = Gtk2::Adjustment->new($adj1, $adj2, 10000, 1, 50, 200 ); | ||
| 152 | my $spin = Gtk2::SpinButton->new($adjust, 1, 0); | ||
| 153 | $self->{$table}->attach($spin, $spinxstart, $spinxend, $ystart, $yend, ['expand', 'fill'], [], 2, 2); | ||
| 154 | $spin->show; | ||
| 155 | $spin->set_size_request(40, -1); | ||
| 156 | $spin; | ||
| 157 | } | ||
| 158 | |||
| 159 | sub check_and_button { | ||
| 160 | my $self = shift; | ||
| 161 | my $table = shift; | ||
| 162 | my $button_text = shift; | ||
| 163 | my $checkxstart = shift; | ||
| 164 | my $checkxend = shift; | ||
| 165 | my $buttonxstart = shift; | ||
| 166 | my $buttonxend = shift; | ||
| 167 | my $ystart = shift; | ||
| 168 | my $yend = shift; | ||
| 169 | |||
| 170 | my $check = $self->check_button($table, $button_text, $checkxstart, $checkxend, $ystart, $yend); | ||
| 171 | my $button = Gtk2::Button->new_from_stock('ar_properties'); | ||
| 172 | $button->show; | ||
| 173 | $button->set_size_request(10, -1); | ||
| 174 | $self->{$table}->attach($button, $buttonxstart, $buttonxend, $ystart, $yend, ['fill'], [], 2, 2); | ||
| 175 | return ($check, $button); | ||
| 176 | } | ||
| 177 | |||
| 178 | sub hbox_label_entry { | ||
| 179 | my $self = shift; | ||
| 180 | my $table = shift; | ||
| 181 | my $label_text = shift; | ||
| 182 | my $xstart = shift; | ||
| 183 | my $xend = shift; | ||
| 184 | my $ystart = shift; | ||
| 185 | my $yend = shift; | ||
| 186 | |||
| 187 | my $hbox = Gtk2::HBox->new(1,5); | ||
| 188 | $hbox->show; | ||
| 189 | $hbox->set_homogeneous(1); | ||
| 190 | |||
| 191 | my $label = Gtk2::Label->new($label_text); | ||
| 192 | $label->set_alignment(0,0.5); | ||
| 193 | $label->show; | ||
| 194 | |||
| 195 | my $entry = Gtk2::Entry->new; | ||
| 196 | $entry->show; | ||
| 197 | $entry->set_sensitive(0); | ||
| 198 | |||
| 199 | $hbox->pack_start_defaults($label); | ||
| 200 | $hbox->pack_end_defaults($entry); | ||
| 201 | $self->{$table}->attach($hbox, $xstart, $xend, $ystart, $yend, ['fill'], [], 2, 2); | ||
| 202 | $entry; | ||
| 203 | } | ||
| 204 | |||
| 205 | sub initialise { | ||
| 206 | my $self = shift; | ||
| 207 | |||
| 208 | $self->{gramofile} = Gtk2::Window->new('toplevel'); | ||
| 209 | my $screen = $self->{gramofile}->get_screen; | ||
| 210 | my $maxw = $screen->get_width - SCREEN_OFF; | ||
| 211 | my $width = APP_WIDTH; | ||
| 212 | $width = $maxw if ($maxw < $width); | ||
| 213 | my $maxh = $screen->get_height - SCREEN_OFF; | ||
| 214 | my $height = APP_HEIGHT; | ||
| 215 | $height = $maxh if ($maxh < $height); | ||
| 216 | $self->{gramofile}->set_default_size($width, $height); | ||
| 217 | $self->{gramofile}->set_title('gramofile'); | ||
| 218 | $self->{gramofile}->set_resizable(1); | ||
| 219 | $self->{gramofile}->realize; | ||
| 220 | |||
| 221 | my $scrolled_window = Gtk2::ScrolledWindow->new(undef, undef); | ||
| 222 | $scrolled_window->set_policy('automatic', 'automatic'); | ||
| 223 | $self->{gramofile}->add($scrolled_window); | ||
| 224 | $scrolled_window->show(); | ||
| 225 | |||
| 226 | $self->{main_vbox} = Gtk2::VBox->new(0, 0); | ||
| 227 | $scrolled_window->add_with_viewport($self->{main_vbox}); | ||
| 228 | $self->{main_vbox}->show; | ||
| 229 | |||
| 230 | $self->{notebook} = Gtk2::Notebook->new; | ||
| 231 | $self->{notebook}->show; | ||
| 232 | $self->{notebook}->set_border_width(2); | ||
| 233 | $self->{main_vbox}->add($self->{notebook}); | ||
| 234 | |||
| 235 | $self->{status_vbox} = Gtk2::VBox->new(0, 0); | ||
| 236 | $self->{main_vbox}->add($self->{status_vbox}); | ||
| 237 | $self->{status_vbox}->show; | ||
| 238 | |||
| 239 | # LOCATE TRACKS TAB | ||
| 240 | |||
| 241 | $self->{tracksplit_frame} = Gtk2::Frame->new('Locate Tracks'); | ||
| 242 | $self->{tracksplit_frame}->set_label_align(0, 0); | ||
| 243 | $self->{notebook}->append_page($self->{tracksplit_frame}, Gtk2::Label->new("Locate Tracks")); | ||
| 244 | $self->{tracksplit_frame}->show; | ||
| 245 | $self->{tracksplit_frame}->set_border_width(2); | ||
| 246 | |||
| 247 | $self->{tracksplit_vbox} = Gtk2::VBox->new(0, 0); | ||
| 248 | $self->{tracksplit_frame}->add($self->{tracksplit_vbox}); | ||
| 249 | $self->{tracksplit_vbox}->show; | ||
| 250 | |||
| 251 | $self->{tracksplit_table} = Gtk2::Table->new(22, 6, 0); | ||
| 252 | $self->{tracksplit_table}->set_row_spacings(ROW_HEIGHT); | ||
| 253 | $self->{tracksplit_vbox}->add($self->{tracksplit_table}); | ||
| 254 | $self->{tracksplit_table}->show; | ||
| 255 | |||
| 256 | $self->{tracksplit_filename_entry} = $self->label_and_entry('tracksplit_table', | ||
| 257 | 'File or Directory name', 0, 2, 2, 6, 0, 1); | ||
| 258 | ($self->{tracksplit_filename_filter_entry}, $self->{tracksplit_browse_button}) = | ||
| 259 | $self->label_and_entry_and_button('tracksplit_table', 'File name filter', 0, 2, 2, 5, 5, 6, 1, 2); | ||
| 260 | $self->separator('tracksplit_table', 0, 6, 2, 3); | ||
| 261 | |||
| 262 | $self->{tracksplit_rms_file_check} = | ||
| 263 | $self->check_button('tracksplit_table', 'Save/load signal power (RMS) data to/from .rms file', 0, 6, 3, 4); | ||
| 264 | $self->{tracksplit_generate_graph_check} = | ||
| 265 | $self->check_button('tracksplit_table', 'Generate graph files', 0, 6, 4, 5); | ||
| 266 | $self->separator('tracksplit_table', 0, 6, 5, 6); | ||
| 267 | $self->{signal_power_data_blocklen_spin} = $self->label_and_spin('tracksplit_table', | ||
| 268 | 'Length of blocks of signal power data (samples)', 0, 5, 5, 6, 6, 7, 0, 0); | ||
| 269 | $self->{global_silence_factor_spin} = $self->label_and_spin('tracksplit_table', | ||
| 270 | 'Global silence factor (0.1 %)', 0, 5, 5, 6, 7, 8, 0, 0); | ||
| 271 | $self->{local_silence_factor_spin} = $self->label_and_spin('tracksplit_table', | ||
| 272 | 'Local silence factor (%)', 0, 5, 5, 6, 8, 9, 1, -2); | ||
| 273 | $self->{inter_track_silence_minlen_spin} = $self->label_and_spin('tracksplit_table', | ||
| 274 | 'Minimal length of inter-track silence (blocks)', 0, 5, 5, 6, 9, 10, 1, -2); | ||
| 275 | $self->{track_minlen_spin} = $self->label_and_spin('tracksplit_table', | ||
| 276 | 'Minimal length of tracks (blocks)', 0, 5, 5, 6, 10, 11, 1, -2); | ||
| 277 | $self->{track_start_extra_blocks_spin} = $self->label_and_spin('tracksplit_table', | ||
| 278 | 'Number of extra blocks at track start', 0, 5, 5, 6, 11, 12, 1, -2); | ||
| 279 | $self->{track_end_extra_blocks_spin} = $self->label_and_spin('tracksplit_table', | ||
| 280 | 'Number of extra blocks at track end', 0, 5, 5, 6, 12, 13, 1, -2); | ||
| 281 | |||
| 282 | $self->{tracksplit_separator2} = Gtk2::HSeparator->new; | ||
| 283 | $self->{tracksplit_separator2}->show; | ||
| 284 | $self->{tracksplit_vbox}->add($self->{tracksplit_separator2}); | ||
| 285 | |||
| 286 | $self->{tracksplit_buttons_table} = Gtk2::Table->new(1, 2, 1); | ||
| 287 | $self->{tracksplit_vbox}->pack_end($self->{tracksplit_buttons_table},0,0,0); | ||
| 288 | $self->{tracksplit_buttons_table}->show; | ||
| 289 | |||
| 290 | $self->{stop_tracksplit_button} = Gtk2::Button->new_from_stock('ar_stop'); | ||
| 291 | $self->{tracksplit_buttons_table}->attach($self->{stop_tracksplit_button}, 0, 1, 0, 1, ['expand', 'fill'], [], 2, 2); | ||
| 292 | $self->{stop_tracksplit_button}->show; | ||
| 293 | $self->{stop_tracksplit_button}->set_sensitive(0); | ||
| 294 | |||
| 295 | $self->{start_tracksplit_button} = Gtk2::Button->new_from_stock('ar_start'); | ||
| 296 | $self->{tracksplit_buttons_table}->attach($self->{start_tracksplit_button}, 1, 2, 0, 1, ['expand', 'fill'], [], 2, 2); | ||
| 297 | $self->{start_tracksplit_button}->show; | ||
| 298 | |||
| 299 | # PROCESS SIGNAL TAB | ||
| 300 | |||
| 301 | $self->{process_frame} = Gtk2::Frame->new('Process Signal'); | ||
| 302 | $self->{process_frame}->set_label_align(0, 0); | ||
| 303 | $self->{notebook}->append_page($self->{process_frame}, Gtk2::Label->new("Process Signal")); | ||
| 304 | $self->{process_frame}->show; | ||
| 305 | $self->{process_frame}->set_border_width(2); | ||
| 306 | |||
| 307 | $self->{process_vbox} = Gtk2::VBox->new(0, 0); | ||
| 308 | $self->{process_frame}->add($self->{process_vbox}); | ||
| 309 | $self->{process_vbox}->show; | ||
| 310 | |||
| 311 | $self->{process_table} = Gtk2::Table->new(22, 6, 0); | ||
| 312 | $self->{process_table}->set_row_spacings(ROW_HEIGHT); | ||
| 313 | $self->{process_vbox}->add($self->{process_table}); | ||
| 314 | $self->{process_table}->show; | ||
| 315 | |||
| 316 | $self->{process_infile_entry} = $self->label_and_entry('process_table', | ||
| 317 | 'Input File or Directory', 0, 2, 2, 6, 0, 1); | ||
| 318 | ($self->{process_infile_filter_entry}, $self->{process_infile_button}) = | ||
| 319 | $self->label_and_entry_and_button('process_table', 'Input File filter', 0, 2, 2, 5, 5, 6, 1, 2); | ||
| 320 | $self->separator('process_table', 0, 6, 2, 3); | ||
| 321 | $self->{process_outfile_entry} = $self->label_and_entry('process_table', | ||
| 322 | 'Output File or Directory', 0, 2, 2, 6, 3, 4); | ||
| 323 | ($self->{process_outfile_filter_entry}, $self->{process_outfile_button}) = | ||
| 324 | $self->label_and_entry_and_button('process_table', 'Output File filter', 0, 2, 2, 5, 5, 6, 4, 5); | ||
| 325 | $self->{process_op_regexp_check} = | ||
| 326 | $self->check_button('process_table', 'Use filter as regexp', 0, 6, 5, 6); | ||
| 327 | $self->separator('process_table', 0, 6, 6, 7); | ||
| 328 | $self->{copyonly_filter_check} = | ||
| 329 | $self->check_button('process_table', 'Copy Only', 0, 6, 7, 8); | ||
| 330 | $self->{monoize_filter_check} = | ||
| 331 | $self->check_button('process_table', 'Mono Filter', 0, 6, 8, 9); | ||
| 332 | ($self->{simple_median_filter_check}, $self->{simple_median_filter_button}) = $self->check_and_button( | ||
| 333 | 'process_table','Simple Median Filter', 0, 5, 5, 6, 9, 10); | ||
| 334 | ($self->{double_median_filter_check}, $self->{double_median_filter_button}) = $self->check_and_button( | ||
| 335 | 'process_table','Double Median Filter', 0, 5, 5, 6, 10, 11); | ||
| 336 | ($self->{simple_mean_filter_check}, $self->{simple_mean_filter_button}) = $self->check_and_button( | ||
| 337 | 'process_table','Simple Mean Filter', 0, 5, 5, 6, 11, 12); | ||
| 338 | ($self->{rms_filter_check}, $self->{rms_filter_button}) = $self->check_and_button( | ||
| 339 | 'process_table','RMS Filter', 0, 5, 5, 6, 12, 13); | ||
| 340 | ($self->{cond_median_filter_check}, $self->{cond_median_filter_button}) = $self->check_and_button( | ||
| 341 | 'process_table','Conditional Median Filter', 0, 5, 5, 6, 13, 14); | ||
| 342 | ($self->{cond_median2_filter_check}, $self->{cond_median2_filter_button}) = $self->check_and_button( | ||
| 343 | 'process_table','Conditional Median Filter II', 0, 5, 5, 6, 14, 15); | ||
| 344 | ($self->{cond_median3_filter_check}, $self->{cond_median3_filter_button}) = $self->check_and_button( | ||
| 345 | 'process_table','Conditional Median Filter IIF', 0, 5, 5, 6, 15, 16); | ||
| 346 | ($self->{simple_normalize_filter_check}, $self->{simple_normalize_filter_button}) = $self->check_and_button( | ||
| 347 | 'process_table','Simple Normalize Filter', 0, 5, 5, 6, 16, 17); | ||
| 348 | $self->{experimenting_filter_check} = | ||
| 349 | $self->check_button('process_table', 'Experimenting Filter', 0, 6, 17, 18); | ||
| 350 | $self->separator('process_table', 0, 6, 18, 19); | ||
| 351 | |||
| 352 | $self->{times_buttons_hbox} = Gtk2::HBox->new(1,5); | ||
| 353 | $self->{times_buttons_hbox}->show; | ||
| 354 | my $times = Gtk2::RadioButton->new; | ||
| 355 | |||
| 356 | $self->{split_tracks_radio} = Gtk2::RadioButton->new_with_label_from_widget($times,'Split tracks'); | ||
| 357 | $self->{split_tracks_radio}->show; | ||
| 358 | $self->{split_tracks_radio}->set_sensitive(1); | ||
| 359 | $self->{times_buttons_hbox}->pack_start_defaults($self->{split_tracks_radio}); | ||
| 360 | |||
| 361 | $self->{begin_and_end_times_radio} = Gtk2::RadioButton->new_with_label_from_widget($times,'Use begin and end times'); | ||
| 362 | $self->{begin_and_end_times_radio}->show; | ||
| 363 | $self->{begin_and_end_times_radio}->set_sensitive(1); | ||
| 364 | $self->{times_buttons_hbox}->pack_start_defaults($self->{begin_and_end_times_radio}); | ||
| 365 | |||
| 366 | $self->{whole_frames_check} = Gtk2::CheckButton->new('Adjust to whole frames'); | ||
| 367 | $self->{whole_frames_check}->set_sensitive(1); | ||
| 368 | $self->{whole_frames_check}->show; | ||
| 369 | $self->{times_buttons_hbox}->pack_end_defaults($self->{whole_frames_check}); | ||
| 370 | |||
| 371 | $self->{process_table}->attach($self->{times_buttons_hbox}, 0, 6, 19, 20, ['fill'], [], 2, 2); | ||
| 372 | |||
| 373 | $self->{process_separator3} = Gtk2::HSeparator->new; | ||
| 374 | $self->{process_separator3}->show; | ||
| 375 | $self->{process_vbox}->add($self->{process_separator3}); | ||
| 376 | |||
| 377 | $self->{process_buttons_table} = Gtk2::Table->new(1, 2, 1); | ||
| 378 | $self->{process_vbox}->pack_end($self->{process_buttons_table},0,0,0); | ||
| 379 | $self->{process_buttons_table}->show; | ||
| 380 | |||
| 381 | $self->{stop_process_button} = Gtk2::Button->new_from_stock('ar_stop'); | ||
| 382 | $self->{process_buttons_table}->attach($self->{stop_process_button}, 0, 1, 0, 1, ['expand', 'fill'], [], 2, 2); | ||
| 383 | $self->{stop_process_button}->show; | ||
| 384 | $self->{stop_process_button}->set_sensitive(0); | ||
| 385 | |||
| 386 | $self->{start_process_button} = Gtk2::Button->new_from_stock('ar_start'); | ||
| 387 | $self->{process_buttons_table}->attach($self->{start_process_button}, 1, 2, 0, 1, ['expand', 'fill'], [], 2, 2); | ||
| 388 | $self->{start_process_button}->show; | ||
| 389 | |||
| 390 | # STATUS BAR AND BUTTONS | ||
| 391 | |||
| 392 | $self->{status_hbox} = Gtk2::HBox->new; | ||
| 393 | $self->{status_hbox}->show; | ||
| 394 | $self->{status_vbox}->add($self->{status_hbox}); | ||
| 395 | $self->{status_bar} = Gtk2::Statusbar->new; | ||
| 396 | $self->{status_hbox}->pack_start($self->{status_bar}, 1, 1, 2); | ||
| 397 | $self->{status_bar}->show; | ||
| 398 | |||
| 399 | $self->{rpsq_hbox} = Gtk2::HBox->new(1,5); | ||
| 400 | $self->{rpsq_hbox}->show; | ||
| 401 | $self->{rpsq_hbox}->set_homogeneous(1); | ||
| 402 | |||
| 403 | $self->{record_button} = Gtk2::Button->new_from_stock('ar_record'); | ||
| 404 | $self->{record_button}->show; | ||
| 405 | $self->{rpsq_hbox}->pack_start_defaults($self->{record_button}); | ||
| 406 | |||
| 407 | $self->{play_button} = Gtk2::Button->new_from_stock('ar_play'); | ||
| 408 | $self->{play_button}->show; | ||
| 409 | $self->{rpsq_hbox}->pack_start_defaults($self->{play_button}); | ||
| 410 | |||
| 411 | $self->{save_button} = Gtk2::Button->new_from_stock('ar_save'); | ||
| 412 | $self->{save_button}->show; | ||
| 413 | $self->{rpsq_hbox}->pack_start_defaults($self->{save_button}); | ||
| 414 | |||
| 415 | $self->{quit_button} = Gtk2::Button->new_from_stock('ar_quit'); | ||
| 416 | $self->{quit_button}->show; | ||
| 417 | $self->{rpsq_hbox}->pack_start_defaults($self->{quit_button}); | ||
| 418 | |||
| 419 | $self->{main_vbox}->add($self->{rpsq_hbox}); | ||
| 420 | |||
| 421 | # TOOLTIPS | ||
| 422 | |||
| 423 | $self->{tooltips} = Gtk2::Tooltips->new(); | ||
| 424 | $self->{tooltips}->set_tip($self->{tracksplit_filename_entry}, "File or Directory name for wav file/s"); | ||
| 425 | $self->{tooltips}->set_tip($self->{tracksplit_filename_filter_entry}, "Filter used on the names of files"); | ||
| 426 | $self->{tooltips}->set_tip($self->{tracksplit_rms_file_check}, "If a file containing RMS data should be generated"); | ||
| 427 | $self->{tooltips}->set_tip($self->{tracksplit_generate_graph_check}, "If a set of graph files should be generated"); | ||
| 428 | $self->{tooltips}->set_tip($self->{local_silence_factor_spin}, "The local silence factor - used to detect track start and end more accurately"); | ||
| 429 | $self->{tooltips}->set_tip($self->{inter_track_silence_minlen_spin}, "Sets the minimum length for the inter track silence"); | ||
| 430 | $self->{tooltips}->set_tip($self->{track_minlen_spin}, "Minimum length of tracks"); | ||
| 431 | $self->{tooltips}->set_tip($self->{track_start_extra_blocks_spin}, "Extra blocks saved at track start"); | ||
| 432 | $self->{tooltips}->set_tip($self->{track_end_extra_blocks_spin}, "Extra blocks saved at track end"); | ||
| 433 | $self->{tooltips}->set_tip($self->{signal_power_data_blocklen_spin}, "Signal Power Data"); | ||
| 434 | $self->{tooltips}->set_tip($self->{global_silence_factor_spin}, "The global silence threshold of the whole sound file"); | ||
| 435 | $self->{tooltips}->set_tip($self->{start_tracksplit_button}, "Start splitting the sound file/s"); | ||
| 436 | $self->{tooltips}->set_tip($self->{stop_tracksplit_button}, "Stop splitting the sound file/s"); | ||
| 437 | |||
| 438 | $self->{tooltips}->set_tip($self->{process_infile_entry}, "Input File or Directory name for wav file/s"); | ||
| 439 | $self->{tooltips}->set_tip($self->{process_infile_filter_entry}, "Filter used on the names of files"); | ||
| 440 | $self->{tooltips}->set_tip($self->{process_outfile_entry}, "Output File or Directory name for wav file/s"); | ||
| 441 | $self->{tooltips}->set_tip($self->{process_outfile_filter_entry}, "Filter used on the names of files"); | ||
| 442 | $self->{tooltips}->set_tip($self->{process_op_regexp_check}, "Use the output filter as a perl regular expression"); | ||
| 443 | $self->{tooltips}->set_tip($self->{copyonly_filter_check}, "Do nothing - just copy the signal unchanged."); | ||
| 444 | $self->{tooltips}->set_tip($self->{monoize_filter_check}, "Average left & right signals."); | ||
| 445 | $self->{tooltips}->set_tip($self->{simple_median_filter_check}, "Interpolate short ticks."); | ||
| 446 | $self->{tooltips}->set_tip($self->{double_median_filter_check}, "Interpolate short ticks and correct interpolations."); | ||
| 447 | $self->{tooltips}->set_tip($self->{simple_mean_filter_check}, "'Smooth' the signal by taking the mean of samples."); | ||
| 448 | $self->{tooltips}->set_tip($self->{rms_filter_check}, "Compute the 'running' Root-Mean-Square of the signal."); | ||
| 449 | $self->{tooltips}->set_tip($self->{cond_median_filter_check}, "Remove ticks while not changing rest of signal."); | ||
| 450 | $self->{tooltips}->set_tip($self->{cond_median2_filter_check}, "Remove ticks while not changing rest of signal - Better."); | ||
| 451 | $self->{tooltips}->set_tip($self->{cond_median3_filter_check}, "Remove ticks while not changing rest of signal - Using frequency domain."); | ||
| 452 | $self->{tooltips}->set_tip($self->{simple_normalize_filter_check}, "Normalize filter - Increase or reduce signal by 0 to +/- 100 %. Use TRACK file to find maximum sample value and apply appropriate factor"); | ||
| 453 | $self->{tooltips}->set_tip($self->{experimenting_filter_check}, "The filter YOU are experimenting with (in signpr_exper.c)."); | ||
| 454 | $self->{tooltips}->set_tip($self->{split_tracks_radio}, "Split wav file into tracks."); | ||
| 455 | $self->{tooltips}->set_tip($self->{begin_and_end_times_radio}, "Process wav file from begin time until end time."); | ||
| 456 | $self->{tooltips}->set_tip($self->{whole_frames_check}, "Specify frame size for processing wav file."); | ||
| 457 | $self->{tooltips}->set_tip($self->{start_process_button}, "Start signal processing the sound file/s"); | ||
| 458 | $self->{tooltips}->set_tip($self->{stop_process_button}, "Stop signal processing the sound file/s"); | ||
| 459 | |||
| 460 | $self->{tooltips}->set_tip($self->{record_button}, "Start recording to file"); | ||
| 461 | $self->{tooltips}->set_tip($self->{play_button}, "Play a file"); | ||
| 462 | $self->{tooltips}->set_tip($self->{save_button}, "Store useful settings in $ENV{HOME}/.gramofilerc"); | ||
| 463 | $self->{tooltips}->set_tip($self->{quit_button}, "Quit GtkGramofile"); | ||
| 464 | |||
| 465 | $self->{notebook}->set_current_page(0); | ||
| 466 | } | ||
| 467 | |||
| 468 | sub on_setting_finished { | ||
| 469 | my $widget = shift; | ||
| 470 | my $tmp = shift; | ||
| 471 | my $cb_data; | ||
| 472 | if (ref $tmp eq 'Gtk2::Gdk::Event::Focus') { | ||
| 473 | $cb_data = shift; | ||
| 474 | } else { | ||
| 475 | $cb_data = $tmp; | ||
| 476 | } | ||
| 477 | my $self = $cb_data->{self}; | ||
| 478 | my $section = $cb_data->{section}; | ||
| 479 | my $name = $cb_data->{name}; | ||
| 480 | my $ref = ref $widget; | ||
| 481 | my $value; | ||
| 482 | |||
| 483 | if ($ref eq "Gtk2::Entry") {$value = $widget->get_text} | ||
| 484 | elsif ($ref eq "Gtk2::SpinButton") {$value = $widget->get_value_as_int} | ||
| 485 | elsif ($ref eq "Gtk2::CheckButton" || $ref eq "Gtk2::ToggleButton" || $ref eq "Gtk2::RadioButton") { | ||
| 486 | if ($widget->get_active) {$value = 1} else {$value = 0}} | ||
| 487 | |||
| 488 | $self->{gtkgramofile}->set_value($section, $name, $value); | ||
| 489 | $self->message("$name has been set to $value"); | ||
| 490 | |||
| 491 | return 0; | ||
| 492 | } | ||
| 493 | |||
| 494 | sub on_setting_changed { | ||
| 495 | my $widget = shift; | ||
| 496 | my $cb_data = shift; | ||
| 497 | my $self = $cb_data->{self}; | ||
| 498 | my $section = $cb_data->{section}; | ||
| 499 | my $name = $cb_data->{name}; | ||
| 500 | my $ref = ref $widget; | ||
| 501 | my $value; | ||
| 502 | |||
| 503 | if ($ref eq "Gtk2::Entry") {$value = $widget->get_text} | ||
| 504 | elsif ($ref eq "Gtk2::SpinButton") {$value = $widget->get_value_as_int} | ||
| 505 | elsif ($ref eq "Gtk2::CheckButton" || $ref eq "Gtk2::ToggleButton") {if ($widget->get_active) {$value = 1} else {$value = 0}} | ||
| 506 | |||
| 507 | $self->{gtkgramofile}->set_value($section, $name, $value); | ||
| 508 | $self->message("$name has been changed to $value"); | ||
| 509 | |||
| 510 | return 1; | ||
| 511 | } | ||
| 512 | |||
| 513 | sub connect_signals { | ||
| 514 | my $self = shift; | ||
| 515 | |||
| 516 | my @callbacks = qw(quit record play save tracksplit_browse start_tracksplit stop_tracksplit process_infile process_outfile | ||
| 517 | simple_median_filter double_median_filter simple_mean_filter rms_filter cond_median_filter cond_median2_filter | ||
| 518 | cond_median3_filter simple_normalize_filter start_process stop_process); | ||
| 519 | |||
| 520 | foreach my $callback (@callbacks) { | ||
| 521 | $self->{$callback."_button"}->signal_connect('clicked', $self->{gtkgramofile}->{signals}->get_callback($callback), $self->{gtkgramofile}->{signals}); | ||
| 522 | } | ||
| 523 | $self->{gramofile}->signal_connect('delete_event', $self->{gtkgramofile}->{signals}->get_callback("quit")); | ||
| 524 | |||
| 525 | foreach my $check (qw(tracksplit_rms_file_check tracksplit_generate_graph_check)) { | ||
| 526 | $self->connect_signal('toggled', $self->{finished}, 'tracksplit_params', $check); | ||
| 527 | } | ||
| 528 | foreach my $spin (qw(global_silence_factor_spin local_silence_factor_spin inter_track_silence_minlen_spin track_minlen_spin track_start_extra_blocks_spin track_end_extra_blocks_spin signal_power_data_blocklen_spin)) { | ||
| 529 | $self->connect_signal('changed', $self->{changed}, 'tracksplit_params', $spin); | ||
| 530 | } | ||
| 531 | $self->connect_signal('changed', $self->{finished}, 'tracksplit_general', 'tracksplit_filename_entry'); | ||
| 532 | $self->connect_signal('focus_out_event', $self->{finished}, 'tracksplit_general', 'tracksplit_filename_entry'); | ||
| 533 | $self->connect_signal('changed', $self->{finished}, 'tracksplit_general', 'tracksplit_filename_filter_entry'); | ||
| 534 | $self->connect_signal('focus_out_event', $self->{finished}, 'tracksplit_general', 'tracksplit_filename_filter_entry'); | ||
| 535 | |||
| 536 | foreach my $entry (qw(process_infile_entry process_infile_filter_entry process_outfile_entry process_outfile_filter_entry)) { | ||
| 537 | $self->connect_signal('changed', $self->{finished}, 'process_params', $entry); | ||
| 538 | } | ||
| 539 | $self->connect_signal('toggled', $self->{finished}, 'process_params', 'process_op_regexp_check'); | ||
| 540 | foreach my $check (qw(copyonly_filter_check monoize_filter_check simple_median_filter_check double_median_filter_check simple_mean_filter_check rms_filter_check cond_median_filter_check cond_median2_filter_check cond_median3_filter_check simple_normalize_filter_check experimenting_filter_check)) { | ||
| 541 | $self->connect_signal('toggled', $self->{finished}, 'process_filters', $check); | ||
| 542 | } | ||
| 543 | $self->{"begin_and_end_times_radio"}->signal_connect('toggled', $self->{gtkgramofile}->{signals}->get_callback("begin_and_end_times_radio"), $self->{gtkgramofile}->{signals}); | ||
| 544 | $self->{"whole_frames_check"}->signal_connect('toggled', $self->{gtkgramofile}->{signals}->get_callback("whole_frames_check"), $self->{gtkgramofile}->{signals}); | ||
| 545 | } | ||
| 546 | |||
| 547 | sub connect_signal { | ||
| 548 | my ($self, $signal, $function, $section, $event) = @_; | ||
| 549 | my $cb_data = {self => $self, section => $section}; | ||
| 550 | (my $name = $event) =~ s/_(spin|entry|check|radio)$//; | ||
| 551 | $cb_data->{name} = $name; | ||
| 552 | $self->{$event}->signal_connect($signal, $function, $cb_data); | ||
| 553 | } | ||
| 554 | |||
| 555 | sub message { | ||
| 556 | my $self = shift; | ||
| 557 | my $data = shift; | ||
| 558 | |||
| 559 | if (defined $self) { | ||
| 560 | my $context_id=$self->{status_bar}->get_context_id('gramofile'); | ||
| 561 | $self->{status_bar}->pop($context_id); | ||
| 562 | $self->{status_bar}->push($context_id, $data); | ||
| 563 | } else { | ||
| 564 | print "GtkGramofile message - $data\n" | ||
| 565 | } | ||
| 566 | } | ||
| 567 | |||
| 568 | sub load_settings_to_interface { | ||
| 569 | my $self = shift; | ||
| 570 | |||
| 571 | my $defaults = $self->{gtkgramofile}->get_defaults; | ||
| 572 | |||
| 573 | foreach my $section (keys %{$defaults}) { | ||
| 574 | foreach my $parameter (keys %{$defaults->{$section}}) { | ||
| 575 | my $value = $self->{gtkgramofile}->get_value($section, $parameter); | ||
| 576 | $self->{$parameter."_entry"}->set_text($value) | ||
| 577 | if defined ($self->{$parameter."_entry"}) and $parameter ne $self->{$parameter."_entry"}->get_text; | ||
| 578 | $self->{$parameter."_spin"}->set_value($value) | ||
| 579 | if defined ($self->{$parameter."_spin"}) and $parameter ne $self->{$parameter."_spin"}->get_value_as_int; | ||
| 580 | $self->{$parameter."_check"}->set_active($value) if defined ($self->{$parameter."_check"}); | ||
| 581 | $self->{$parameter."_radio"}->set_active($value) if defined ($self->{$parameter."_radio"}); | ||
| 582 | } | ||
| 583 | } | ||
| 584 | } | ||
| 585 | |||
| 586 | 1; | ||