| 1 |
/* |
|---|
| 2 |
* Sweep, a sound wave editor. |
|---|
| 3 |
* |
|---|
| 4 |
* Copyright (C) 2000 Conrad Parker |
|---|
| 5 |
* |
|---|
| 6 |
* This program is free software; you can redistribute it and/or modify |
|---|
| 7 |
* it under the terms of the GNU General Public License as published by |
|---|
| 8 |
* the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 |
* (at your option) any later version. |
|---|
| 10 |
* |
|---|
| 11 |
* This program is distributed in the hope that it will be useful, |
|---|
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 |
* GNU General Public License for more details. |
|---|
| 15 |
* |
|---|
| 16 |
* You should have received a copy of the GNU General Public License |
|---|
| 17 |
* along with this program; if not, write to the Free Software |
|---|
| 18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 19 |
*/ |
|---|
| 20 |
|
|---|
| 21 |
#ifdef HAVE_CONFIG_H |
|---|
| 22 |
# include <config.h> |
|---|
| 23 |
#endif |
|---|
| 24 |
|
|---|
| 25 |
#include <stdio.h> |
|---|
| 26 |
#include <string.h> |
|---|
| 27 |
#include <stdlib.h> |
|---|
| 28 |
|
|---|
| 29 |
#include <gtk/gtk.h> |
|---|
| 30 |
|
|---|
| 31 |
#include "callbacks.h" |
|---|
| 32 |
|
|---|
| 33 |
#include <sweep/sweep_i18n.h> |
|---|
| 34 |
#include <sweep/sweep_types.h> |
|---|
| 35 |
#include <sweep/sweep_undo.h> |
|---|
| 36 |
#include <sweep/sweep_sample.h> |
|---|
| 37 |
#include <sweep/sweep_typeconvert.h> |
|---|
| 38 |
|
|---|
| 39 |
#include "sample.h" |
|---|
| 40 |
#include "interface.h" |
|---|
| 41 |
#include "edit.h" |
|---|
| 42 |
#include "head.h" |
|---|
| 43 |
#include "sample-display.h" |
|---|
| 44 |
#include "play.h" |
|---|
| 45 |
#include "driver.h" |
|---|
| 46 |
#include "undo_dialog.h" |
|---|
| 47 |
#include "paste_dialogs.h" |
|---|
| 48 |
#include "print.h" |
|---|
| 49 |
#include "record.h" |
|---|
| 50 |
#include "file_dialogs.h" |
|---|
| 51 |
|
|---|
| 52 |
/* |
|---|
| 53 |
* Default zooming parameters. |
|---|
| 54 |
* |
|---|
| 55 |
* DEFAULT_ZOOM sets the ratio for zooming. Each time zoom_in is |
|---|
| 56 |
* called, the view is adjusted to be 1/DEFAULT_ZOOM its current |
|---|
| 57 |
* length. Each time zoom_out is called, the view is adjusted to |
|---|
| 58 |
* DEFAULT_ZOOM times its current length. |
|---|
| 59 |
* |
|---|
| 60 |
* If you alter this, make sure |
|---|
| 61 |
* (DEFAULT_ZOOM - 1) * DEFAULT_MIN_ZOOM > 1 |
|---|
| 62 |
* |
|---|
| 63 |
* where DEFAULT_MIN_ZOOM is defined in view.c |
|---|
| 64 |
*/ |
|---|
| 65 |
#define DEFAULT_ZOOM 2.0 |
|---|
| 66 |
|
|---|
| 67 |
#define ZOOM_FRAMERATE 10 |
|---|
| 68 |
|
|---|
| 69 |
/* Sample creation */ |
|---|
| 70 |
|
|---|
| 71 |
void |
|---|
| 72 |
sample_new_empty_cb (GtkWidget * widget, gpointer data) |
|---|
| 73 |
{ |
|---|
| 74 |
sw_view * view = (sw_view *)data; |
|---|
| 75 |
|
|---|
| 76 |
if (view == NULL) { |
|---|
| 77 |
create_sample_new_dialog_defaults (NULL); |
|---|
| 78 |
} else { |
|---|
| 79 |
create_sample_new_dialog_like (view->sample); |
|---|
| 80 |
} |
|---|
| 81 |
} |
|---|
| 82 |
|
|---|
| 83 |
void |
|---|
| 84 |
sample_new_copy_cb (GtkWidget * widget, gpointer data) |
|---|
| 85 |
{ |
|---|
| 86 |
sw_sample * ns; |
|---|
| 87 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 88 |
sw_sample * s; |
|---|
| 89 |
sw_view * v; |
|---|
| 90 |
|
|---|
| 91 |
s = sd->view->sample; |
|---|
| 92 |
|
|---|
| 93 |
if(!s) return; |
|---|
| 94 |
|
|---|
| 95 |
ns = sample_new_copy(s); |
|---|
| 96 |
|
|---|
| 97 |
while (ns->color == s->color) { |
|---|
| 98 |
ns->color = (random()) % VIEW_COLOR_MAX; |
|---|
| 99 |
} |
|---|
| 100 |
|
|---|
| 101 |
v = view_new_all (ns, 1.0); |
|---|
| 102 |
sample_add_view (ns, v); |
|---|
| 103 |
|
|---|
| 104 |
sample_bank_add(ns); |
|---|
| 105 |
} |
|---|
| 106 |
|
|---|
| 107 |
/* Generic repeater */ |
|---|
| 108 |
|
|---|
| 109 |
static void |
|---|
| 110 |
view_init_repeater (sw_view * view, GtkFunction function, gpointer data) |
|---|
| 111 |
{ |
|---|
| 112 |
function (data); |
|---|
| 113 |
if (view->repeater_tag <= 0) { |
|---|
| 114 |
view->repeater_tag = g_timeout_add ((guint32)1000/ZOOM_FRAMERATE, |
|---|
| 115 |
(GSourceFunc) function, data); |
|---|
| 116 |
} |
|---|
| 117 |
} |
|---|
| 118 |
|
|---|
| 119 |
void |
|---|
| 120 |
repeater_released_cb (GtkWidget * widget, gpointer data) |
|---|
| 121 |
{ |
|---|
| 122 |
sw_view * view = (sw_view *)data; |
|---|
| 123 |
|
|---|
| 124 |
if (view->repeater_tag > 0) { |
|---|
| 125 |
g_source_remove(view->repeater_tag); |
|---|
| 126 |
view->repeater_tag = 0; |
|---|
| 127 |
} |
|---|
| 128 |
} |
|---|
| 129 |
|
|---|
| 130 |
/* View */ |
|---|
| 131 |
|
|---|
| 132 |
void |
|---|
| 133 |
view_new_all_cb (GtkWidget * widget, gpointer data) |
|---|
| 134 |
{ |
|---|
| 135 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 136 |
sw_sample * s; |
|---|
| 137 |
sw_view * v; |
|---|
| 138 |
|
|---|
| 139 |
s = sd->view->sample; |
|---|
| 140 |
v = view_new_all(s, 1.0); |
|---|
| 141 |
|
|---|
| 142 |
sample_add_view (s, v); |
|---|
| 143 |
} |
|---|
| 144 |
|
|---|
| 145 |
void |
|---|
| 146 |
view_new_cb (GtkWidget * widget, gpointer data) |
|---|
| 147 |
{ |
|---|
| 148 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 149 |
sw_sample * s; |
|---|
| 150 |
sw_view * view, * v; |
|---|
| 151 |
|
|---|
| 152 |
v = sd->view; |
|---|
| 153 |
s = v->sample; |
|---|
| 154 |
|
|---|
| 155 |
view = view_new (s, v->start, v->end, s->play_head->gain); |
|---|
| 156 |
|
|---|
| 157 |
sample_add_view (s, view); |
|---|
| 158 |
} |
|---|
| 159 |
|
|---|
| 160 |
void |
|---|
| 161 |
view_close_cb (GtkWidget * widget, gpointer data) |
|---|
| 162 |
{ |
|---|
| 163 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 164 |
sw_view * v; |
|---|
| 165 |
|
|---|
| 166 |
v = sd->view; |
|---|
| 167 |
|
|---|
| 168 |
view_close(v); |
|---|
| 169 |
} |
|---|
| 170 |
|
|---|
| 171 |
void |
|---|
| 172 |
exit_cb (GtkWidget * widget, gpointer data) |
|---|
| 173 |
{ |
|---|
| 174 |
sweep_quit (); |
|---|
| 175 |
} |
|---|
| 176 |
|
|---|
| 177 |
/* Tools */ |
|---|
| 178 |
void |
|---|
| 179 |
set_tool_cb (GtkWidget * widget, gpointer data) |
|---|
| 180 |
{ |
|---|
| 181 |
g_print ("NOOOOOOOOOOOOOO global current_tool\n"); |
|---|
| 182 |
} |
|---|
| 183 |
|
|---|
| 184 |
void |
|---|
| 185 |
view_set_tool_cb (GtkWidget * widget, gpointer data) |
|---|
| 186 |
{ |
|---|
| 187 |
sw_view * view = (sw_view *)data; |
|---|
| 188 |
sw_tool_t tool; |
|---|
| 189 |
|
|---|
| 190 |
tool = (sw_tool_t) |
|---|
| 191 |
GPOINTER_TO_INT(g_object_get_data (G_OBJECT(widget), "default")); |
|---|
| 192 |
|
|---|
| 193 |
view->current_tool = tool; |
|---|
| 194 |
|
|---|
| 195 |
view_refresh_tool_buttons (view); |
|---|
| 196 |
} |
|---|
| 197 |
|
|---|
| 198 |
/* Zooming */ |
|---|
| 199 |
|
|---|
| 200 |
static gboolean |
|---|
| 201 |
zoom_in_step (gpointer data) |
|---|
| 202 |
{ |
|---|
| 203 |
sw_view * view = (sw_view *)data; |
|---|
| 204 |
|
|---|
| 205 |
view_zoom_in (view, DEFAULT_ZOOM); |
|---|
| 206 |
|
|---|
| 207 |
return TRUE; |
|---|
| 208 |
} |
|---|
| 209 |
|
|---|
| 210 |
void |
|---|
| 211 |
zoom_in_cb (GtkWidget * widget, gpointer data) |
|---|
| 212 |
{ |
|---|
| 213 |
sw_view * view = (sw_view *)data; |
|---|
| 214 |
view_zoom_in (view, DEFAULT_ZOOM); |
|---|
| 215 |
} |
|---|
| 216 |
|
|---|
| 217 |
static gboolean |
|---|
| 218 |
zoom_out_step (gpointer data) |
|---|
| 219 |
{ |
|---|
| 220 |
sw_view * view = (sw_view *)data; |
|---|
| 221 |
|
|---|
| 222 |
view_zoom_out (view, DEFAULT_ZOOM); |
|---|
| 223 |
|
|---|
| 224 |
return TRUE; |
|---|
| 225 |
} |
|---|
| 226 |
|
|---|
| 227 |
void |
|---|
| 228 |
zoom_out_cb (GtkWidget * widget, gpointer data) |
|---|
| 229 |
{ |
|---|
| 230 |
sw_view * view = (sw_view *)data; |
|---|
| 231 |
view_zoom_out (view, DEFAULT_ZOOM); |
|---|
| 232 |
} |
|---|
| 233 |
|
|---|
| 234 |
|
|---|
| 235 |
void |
|---|
| 236 |
zoom_in_pressed_cb (GtkWidget * widget, gpointer data) |
|---|
| 237 |
{ |
|---|
| 238 |
sw_view * view = (sw_view *)data; |
|---|
| 239 |
|
|---|
| 240 |
view_zoom_in (view, DEFAULT_ZOOM); |
|---|
| 241 |
view_init_repeater (view, (GtkFunction)zoom_in_step, data); |
|---|
| 242 |
} |
|---|
| 243 |
|
|---|
| 244 |
void |
|---|
| 245 |
zoom_out_pressed_cb (GtkWidget * widget, gpointer data) |
|---|
| 246 |
{ |
|---|
| 247 |
sw_view * view = (sw_view *)data; |
|---|
| 248 |
|
|---|
| 249 |
view_zoom_out (view, DEFAULT_ZOOM); |
|---|
| 250 |
view_init_repeater (view, (GtkFunction)zoom_out_step, data); |
|---|
| 251 |
} |
|---|
| 252 |
|
|---|
| 253 |
void |
|---|
| 254 |
zoom_to_sel_cb (GtkWidget * widget, gpointer data) |
|---|
| 255 |
{ |
|---|
| 256 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 257 |
sw_view * v = sd->view; |
|---|
| 258 |
|
|---|
| 259 |
view_zoom_to_sel (v); |
|---|
| 260 |
} |
|---|
| 261 |
|
|---|
| 262 |
void |
|---|
| 263 |
zoom_left_cb (GtkWidget * widget, gpointer data) |
|---|
| 264 |
{ |
|---|
| 265 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 266 |
sw_view * v = sd->view; |
|---|
| 267 |
|
|---|
| 268 |
view_zoom_left (v); |
|---|
| 269 |
} |
|---|
| 270 |
|
|---|
| 271 |
void |
|---|
| 272 |
zoom_right_cb (GtkWidget * widget, gpointer data) |
|---|
| 273 |
{ |
|---|
| 274 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 275 |
sw_view * v = sd->view; |
|---|
| 276 |
|
|---|
| 277 |
view_zoom_right (v); |
|---|
| 278 |
} |
|---|
| 279 |
|
|---|
| 280 |
void |
|---|
| 281 |
zoom_all_cb (GtkWidget * widget, gpointer data) |
|---|
| 282 |
{ |
|---|
| 283 |
sw_view * v = (sw_view *)data; |
|---|
| 284 |
|
|---|
| 285 |
view_zoom_all (v); |
|---|
| 286 |
} |
|---|
| 287 |
|
|---|
| 288 |
/* XXX: dump this ?? */ |
|---|
| 289 |
void |
|---|
| 290 |
zoom_2_1_cb (GtkWidget * widget, gpointer data) |
|---|
| 291 |
{ |
|---|
| 292 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 293 |
sw_sample * s; |
|---|
| 294 |
|
|---|
| 295 |
s = sd->view->sample; |
|---|
| 296 |
|
|---|
| 297 |
view_set_ends(sd->view, |
|---|
| 298 |
s->sounddata->nr_frames / 4, |
|---|
| 299 |
3 * s->sounddata->nr_frames / 4); |
|---|
| 300 |
} |
|---|
| 301 |
|
|---|
| 302 |
void |
|---|
| 303 |
zoom_norm_cb (GtkWidget * widget, gpointer data) |
|---|
| 304 |
{ |
|---|
| 305 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 306 |
sw_view * view = sd->view; |
|---|
| 307 |
|
|---|
| 308 |
view_zoom_normal (view); |
|---|
| 309 |
} |
|---|
| 310 |
|
|---|
| 311 |
void |
|---|
| 312 |
zoom_1to1_cb (GtkWidget * widget, gpointer data) |
|---|
| 313 |
{ |
|---|
| 314 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 315 |
|
|---|
| 316 |
view_zoom_length (sd->view, sd->width); |
|---|
| 317 |
view_center_on (sd->view, sd->view->sample->user_offset); |
|---|
| 318 |
} |
|---|
| 319 |
|
|---|
| 320 |
void |
|---|
| 321 |
zoom_center_cb (GtkWidget * widget, gpointer data) |
|---|
| 322 |
{ |
|---|
| 323 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 324 |
|
|---|
| 325 |
view_center_on (sd->view, sd->view->sample->user_offset); |
|---|
| 326 |
} |
|---|
| 327 |
|
|---|
| 328 |
void |
|---|
| 329 |
zoom_combo_changed_cb (GtkWidget * widget, gpointer data) |
|---|
| 330 |
{ |
|---|
| 331 |
sw_view * view = (sw_view *)data; |
|---|
| 332 |
gchar * text; |
|---|
| 333 |
sw_time_t zoom_time; |
|---|
| 334 |
sw_framecount_t zoom_length; |
|---|
| 335 |
|
|---|
| 336 |
text = (gchar *) gtk_entry_get_text (GTK_ENTRY(widget)); |
|---|
| 337 |
|
|---|
| 338 |
if (!strcmp (text, "All")) { |
|---|
| 339 |
view_zoom_all (view); |
|---|
| 340 |
} else { |
|---|
| 341 |
zoom_time = (sw_time_t)strtime_to_seconds (text); |
|---|
| 342 |
if (zoom_time != -1.0) { |
|---|
| 343 |
zoom_length = |
|---|
| 344 |
time_to_frames (view->sample->sounddata->format, zoom_time); |
|---|
| 345 |
|
|---|
| 346 |
view_zoom_length (view, zoom_length); |
|---|
| 347 |
|
|---|
| 348 |
/* Work around a bug, probably in gtkcombo, whereby all the other |
|---|
| 349 |
* widgets sometimes lost input after choosing a zoom */ |
|---|
| 350 |
gtk_widget_grab_focus (view->display); |
|---|
| 351 |
} |
|---|
| 352 |
} |
|---|
| 353 |
} |
|---|
| 354 |
|
|---|
| 355 |
/* Device config */ |
|---|
| 356 |
|
|---|
| 357 |
void |
|---|
| 358 |
device_config_cb (GtkWidget * widget, gpointer data) |
|---|
| 359 |
{ |
|---|
| 360 |
device_config (); |
|---|
| 361 |
} |
|---|
| 362 |
|
|---|
| 363 |
/* Sample */ |
|---|
| 364 |
|
|---|
| 365 |
void |
|---|
| 366 |
sample_set_color_cb (GtkWidget * widget, gpointer data) |
|---|
| 367 |
{ |
|---|
| 368 |
sw_view * view = (sw_view *) data; |
|---|
| 369 |
gint color; |
|---|
| 370 |
|
|---|
| 371 |
color = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(widget), "default")); |
|---|
| 372 |
sample_set_color (view->sample, color); |
|---|
| 373 |
} |
|---|
| 374 |
|
|---|
| 375 |
/* Playback */ |
|---|
| 376 |
|
|---|
| 377 |
void |
|---|
| 378 |
follow_toggled_cb (GtkWidget * widget, gpointer data) |
|---|
| 379 |
{ |
|---|
| 380 |
sw_view * view = (sw_view *) data; |
|---|
| 381 |
gboolean active; |
|---|
| 382 |
|
|---|
| 383 |
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); |
|---|
| 384 |
view_set_following (view, active); |
|---|
| 385 |
} |
|---|
| 386 |
|
|---|
| 387 |
void |
|---|
| 388 |
follow_toggle_cb (GtkWidget * widget, gpointer data) |
|---|
| 389 |
{ |
|---|
| 390 |
sw_view * view = (sw_view *)data; |
|---|
| 391 |
view_set_following (view, !view->following); |
|---|
| 392 |
} |
|---|
| 393 |
|
|---|
| 394 |
void |
|---|
| 395 |
loop_toggled_cb (GtkWidget * widget, gpointer data) |
|---|
| 396 |
{ |
|---|
| 397 |
sw_view * view = (sw_view *) data; |
|---|
| 398 |
gboolean active; |
|---|
| 399 |
|
|---|
| 400 |
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); |
|---|
| 401 |
sample_set_looping (view->sample, active); |
|---|
| 402 |
} |
|---|
| 403 |
|
|---|
| 404 |
void |
|---|
| 405 |
loop_toggle_cb (GtkWidget * widget, gpointer data) |
|---|
| 406 |
{ |
|---|
| 407 |
sw_view * view = (sw_view *)data; |
|---|
| 408 |
sample_set_looping (view->sample, !view->sample->play_head->looping); |
|---|
| 409 |
} |
|---|
| 410 |
|
|---|
| 411 |
void |
|---|
| 412 |
playrev_toggled_cb (GtkWidget * widget, gpointer data) |
|---|
| 413 |
{ |
|---|
| 414 |
sw_view * view = (sw_view *) data; |
|---|
| 415 |
gboolean active; |
|---|
| 416 |
|
|---|
| 417 |
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); |
|---|
| 418 |
sample_set_playrev (view->sample, active); |
|---|
| 419 |
} |
|---|
| 420 |
|
|---|
| 421 |
void |
|---|
| 422 |
playrev_toggle_cb (GtkWidget * widget, gpointer data) |
|---|
| 423 |
{ |
|---|
| 424 |
sw_view * view = (sw_view *)data; |
|---|
| 425 |
sample_set_playrev (view->sample, !view->sample->play_head->reverse); |
|---|
| 426 |
} |
|---|
| 427 |
|
|---|
| 428 |
void |
|---|
| 429 |
mute_toggled_cb (GtkWidget * widget, gpointer data) |
|---|
| 430 |
{ |
|---|
| 431 |
sw_view * view = (sw_view *) data; |
|---|
| 432 |
gboolean active; |
|---|
| 433 |
|
|---|
| 434 |
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); |
|---|
| 435 |
sample_set_mute (view->sample, active); |
|---|
| 436 |
} |
|---|
| 437 |
|
|---|
| 438 |
void |
|---|
| 439 |
mute_toggle_cb (GtkWidget * widget, gpointer data) |
|---|
| 440 |
{ |
|---|
| 441 |
sw_view * view = (sw_view *)data; |
|---|
| 442 |
sample_set_mute (view->sample, !view->sample->play_head->mute); |
|---|
| 443 |
} |
|---|
| 444 |
|
|---|
| 445 |
void |
|---|
| 446 |
monitor_toggled_cb (GtkWidget * widget, gpointer data) |
|---|
| 447 |
{ |
|---|
| 448 |
sw_view * view = (sw_view *) data; |
|---|
| 449 |
gboolean active; |
|---|
| 450 |
|
|---|
| 451 |
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); |
|---|
| 452 |
sample_set_monitor (view->sample, active); |
|---|
| 453 |
} |
|---|
| 454 |
|
|---|
| 455 |
void |
|---|
| 456 |
monitor_toggle_cb (GtkWidget * widget, gpointer data) |
|---|
| 457 |
{ |
|---|
| 458 |
sw_view * view = (sw_view *)data; |
|---|
| 459 |
sample_set_monitor (view->sample, !view->sample->play_head->monitor); |
|---|
| 460 |
} |
|---|
| 461 |
|
|---|
| 462 |
void |
|---|
| 463 |
play_view_button_cb (GtkWidget * widget, gpointer data) |
|---|
| 464 |
{ |
|---|
| 465 |
sw_view * view = (sw_view *) data; |
|---|
| 466 |
sw_head * head = view->sample->play_head; |
|---|
| 467 |
gboolean was_restricted = head->restricted; |
|---|
| 468 |
|
|---|
| 469 |
head_set_rate (head, 1.0); |
|---|
| 470 |
/* head_set_restricted (head, FALSE);*/ |
|---|
| 471 |
|
|---|
| 472 |
if (head->going && (head->scrubbing || !was_restricted)) { |
|---|
| 473 |
pause_playback_cb (widget, data); |
|---|
| 474 |
} else { |
|---|
| 475 |
play_view_all (view); |
|---|
| 476 |
} |
|---|
| 477 |
} |
|---|
| 478 |
|
|---|
| 479 |
void |
|---|
| 480 |
play_view_cb (GtkWidget * widget, gpointer data) |
|---|
| 481 |
{ |
|---|
| 482 |
sw_view * view = (sw_view *) data; |
|---|
| 483 |
sw_head * head = view->sample->play_head; |
|---|
| 484 |
|
|---|
| 485 |
head_set_rate (head, 1.0); |
|---|
| 486 |
/* head_set_restricted (head, FALSE);*/ |
|---|
| 487 |
|
|---|
| 488 |
if (head->going) { |
|---|
| 489 |
pause_playback_cb (widget, data); |
|---|
| 490 |
} else { |
|---|
| 491 |
play_view_all (view); |
|---|
| 492 |
} |
|---|
| 493 |
} |
|---|
| 494 |
|
|---|
| 495 |
void |
|---|
| 496 |
play_view_sel_button_cb (GtkWidget * widget, gpointer data) |
|---|
| 497 |
{ |
|---|
| 498 |
sw_view * view = (sw_view *) data; |
|---|
| 499 |
sw_head * head = view->sample->play_head; |
|---|
| 500 |
gboolean was_restricted = head->restricted; |
|---|
| 501 |
|
|---|
| 502 |
if (view->sample->sounddata->sels == NULL) { |
|---|
| 503 |
play_view_cb (widget, data); |
|---|
| 504 |
return; |
|---|
| 505 |
} |
|---|
| 506 |
|
|---|
| 507 |
head_set_rate (head, 1.0); |
|---|
| 508 |
/* head_set_restricted (head, TRUE);*/ |
|---|
| 509 |
|
|---|
| 510 |
if (head->going && (head->scrubbing || was_restricted)) { |
|---|
| 511 |
pause_playback_cb (widget, data); |
|---|
| 512 |
} else { |
|---|
| 513 |
play_view_sel (view); |
|---|
| 514 |
} |
|---|
| 515 |
} |
|---|
| 516 |
|
|---|
| 517 |
void |
|---|
| 518 |
play_view_sel_cb (GtkWidget * widget, gpointer data) |
|---|
| 519 |
{ |
|---|
| 520 |
sw_view * view = (sw_view *) data; |
|---|
| 521 |
sw_head * head = view->sample->play_head; |
|---|
| 522 |
|
|---|
| 523 |
if (view->sample->sounddata->sels == NULL) { |
|---|
| 524 |
play_view_cb (widget, data); |
|---|
| 525 |
return; |
|---|
| 526 |
} |
|---|
| 527 |
|
|---|
| 528 |
head_set_rate (head, 1.0); |
|---|
| 529 |
/* head_set_restricted (head, TRUE);*/ |
|---|
| 530 |
|
|---|
| 531 |
if (head->going) { |
|---|
| 532 |
pause_playback_cb (widget, data); |
|---|
| 533 |
} else { |
|---|
| 534 |
play_view_sel (view); |
|---|
| 535 |
} |
|---|
| 536 |
} |
|---|
| 537 |
|
|---|
| 538 |
void |
|---|
| 539 |
pause_playback_cb (GtkWidget * widget, gpointer data) |
|---|
| 540 |
{ |
|---|
| 541 |
sw_view * view = (sw_view *)data; |
|---|
| 542 |
|
|---|
| 543 |
pause_playback (view->sample); |
|---|
| 544 |
} |
|---|
| 545 |
|
|---|
| 546 |
void |
|---|
| 547 |
stop_playback_cb (GtkWidget * widget, gpointer data) |
|---|
| 548 |
{ |
|---|
| 549 |
sw_view * view = (sw_view *)data; |
|---|
| 550 |
|
|---|
| 551 |
stop_playback (view->sample); |
|---|
| 552 |
} |
|---|
| 553 |
|
|---|
| 554 |
void |
|---|
| 555 |
preview_cut_cb (GtkWidget * widget, gpointer data) |
|---|
| 556 |
{ |
|---|
| 557 |
sw_view * view = (sw_view *) data; |
|---|
| 558 |
|
|---|
| 559 |
sample_refresh_playmode (view->sample); |
|---|
| 560 |
|
|---|
| 561 |
if (view->sample->sounddata->sels != NULL) { |
|---|
| 562 |
play_preview_cut (view); |
|---|
| 563 |
} else { |
|---|
| 564 |
play_preroll (view); |
|---|
| 565 |
} |
|---|
| 566 |
} |
|---|
| 567 |
|
|---|
| 568 |
void |
|---|
| 569 |
preroll_cb (GtkWidget * widget, gpointer data) |
|---|
| 570 |
{ |
|---|
| 571 |
sw_view * view = (sw_view *) data; |
|---|
| 572 |
|
|---|
| 573 |
sample_refresh_playmode (view->sample); |
|---|
| 574 |
|
|---|
| 575 |
play_preroll (view); |
|---|
| 576 |
} |
|---|
| 577 |
|
|---|
| 578 |
/* Record */ |
|---|
| 579 |
|
|---|
| 580 |
void |
|---|
| 581 |
show_rec_dialog_cb (GtkWidget * widget, gpointer data) |
|---|
| 582 |
{ |
|---|
| 583 |
sw_view * view = (sw_view *)data; |
|---|
| 584 |
|
|---|
| 585 |
rec_dialog_create (view->sample); |
|---|
| 586 |
} |
|---|
| 587 |
|
|---|
| 588 |
/* Transport */ |
|---|
| 589 |
|
|---|
| 590 |
static gboolean |
|---|
| 591 |
rewind_step (gpointer data) |
|---|
| 592 |
{ |
|---|
| 593 |
sw_sample * sample = (sw_sample *)data; |
|---|
| 594 |
gint step; |
|---|
| 595 |
|
|---|
| 596 |
step = sample->sounddata->format->rate; /* 1 second */ |
|---|
| 597 |
sample_set_playmarker (sample, sample->user_offset - step, TRUE); |
|---|
| 598 |
|
|---|
| 599 |
return TRUE; |
|---|
| 600 |
} |
|---|
| 601 |
|
|---|
| 602 |
static gboolean |
|---|
| 603 |
ffwd_step (gpointer data) |
|---|
| 604 |
{ |
|---|
| 605 |
sw_sample * sample = (sw_sample *)data; |
|---|
| 606 |
gint step; |
|---|
| 607 |
|
|---|
| 608 |
step = sample->sounddata->format->rate; /* 1 second */ |
|---|
| 609 |
sample_set_playmarker (sample, sample->user_offset + step, TRUE); |
|---|
| 610 |
|
|---|
| 611 |
return TRUE; |
|---|
| 612 |
} |
|---|
| 613 |
|
|---|
| 614 |
void |
|---|
| 615 |
page_back_cb (GtkWidget * widget, gpointer data) |
|---|
| 616 |
{ |
|---|
| 617 |
sw_view * view = (sw_view *)data; |
|---|
| 618 |
sw_sample * sample = view->sample; |
|---|
| 619 |
gint step; |
|---|
| 620 |
|
|---|
| 621 |
step = MIN(sample->sounddata->format->rate, (view->end - view->start)); |
|---|
| 622 |
sample_set_playmarker (sample, sample->user_offset - step, TRUE); |
|---|
| 623 |
} |
|---|
| 624 |
|
|---|
| 625 |
void |
|---|
| 626 |
page_fwd_cb (GtkWidget * widget, gpointer data) |
|---|
| 627 |
{ |
|---|
| 628 |
sw_view * view = (sw_view *)data; |
|---|
| 629 |
sw_sample * sample = view->sample; |
|---|
| 630 |
gint step; |
|---|
| 631 |
|
|---|
| 632 |
step = MIN(sample->sounddata->format->rate, (view->end - view->start)); |
|---|
| 633 |
sample_set_playmarker (sample, sample->user_offset + step, TRUE); |
|---|
| 634 |
} |
|---|
| 635 |
|
|---|
| 636 |
void |
|---|
| 637 |
rewind_pressed_cb (GtkWidget * widget, gpointer data) |
|---|
| 638 |
{ |
|---|
| 639 |
sw_view * view = (sw_view *)data; |
|---|
| 640 |
sw_sample * sample = view->sample; |
|---|
| 641 |
|
|---|
| 642 |
view_init_repeater (view, (GtkFunction)rewind_step, sample); |
|---|
| 643 |
} |
|---|
| 644 |
|
|---|
| 645 |
void |
|---|
| 646 |
ffwd_pressed_cb (GtkWidget * widget, gpointer data) |
|---|
| 647 |
{ |
|---|
| 648 |
sw_view * view = (sw_view *)data; |
|---|
| 649 |
sw_sample * sample = view->sample; |
|---|
| 650 |
|
|---|
| 651 |
view_init_repeater (view, (GtkFunction)ffwd_step, sample); |
|---|
| 652 |
} |
|---|
| 653 |
|
|---|
| 654 |
void |
|---|
| 655 |
goto_start_cb (GtkWidget * widget, gpointer data) |
|---|
| 656 |
{ |
|---|
| 657 |
sw_view * view = (sw_view *)data; |
|---|
| 658 |
sw_sample * sample = view->sample; |
|---|
| 659 |
|
|---|
| 660 |
sample_set_scrubbing (sample, FALSE); |
|---|
| 661 |
sample_set_playmarker (sample, 0, TRUE); |
|---|
| 662 |
} |
|---|
| 663 |
|
|---|
| 664 |
void |
|---|
| 665 |
goto_start_of_view_cb (GtkWidget * widget, gpointer data) |
|---|
| 666 |
{ |
|---|
| 667 |
sw_view * view = (sw_view *)data; |
|---|
| 668 |
sw_sample * sample = view->sample; |
|---|
| 669 |
|
|---|
| 670 |
sample_set_scrubbing (sample, FALSE); |
|---|
| 671 |
sample_set_playmarker (sample, view->start, TRUE); |
|---|
| 672 |
} |
|---|
| 673 |
|
|---|
| 674 |
void |
|---|
| 675 |
goto_end_of_view_cb (GtkWidget * widget, gpointer data) |
|---|
| 676 |
{ |
|---|
| 677 |
sw_view * view = (sw_view *)data; |
|---|
| 678 |
sw_sample * sample = view->sample; |
|---|
| 679 |
|
|---|
| 680 |
sample_set_scrubbing (sample, FALSE); |
|---|
| 681 |
sample_set_playmarker (sample, view->end, TRUE); |
|---|
| 682 |
} |
|---|
| 683 |
|
|---|
| 684 |
void |
|---|
| 685 |
goto_end_cb (GtkWidget * widget, gpointer data) |
|---|
| 686 |
{ |
|---|
| 687 |
sw_view * view = (sw_view *)data; |
|---|
| 688 |
sw_sample * sample = view->sample; |
|---|
| 689 |
|
|---|
| 690 |
sample_set_scrubbing (sample, FALSE); |
|---|
| 691 |
sample_set_playmarker (sample, sample->sounddata->nr_frames, TRUE); |
|---|
| 692 |
} |
|---|
| 693 |
|
|---|
| 694 |
/* Interface elements: sample display, scrollbars etc. */ |
|---|
| 695 |
|
|---|
| 696 |
void |
|---|
| 697 |
sd_sel_changed_cb (GtkWidget * widget) |
|---|
| 698 |
{ |
|---|
| 699 |
SampleDisplay * sd = SAMPLE_DISPLAY(widget); |
|---|
| 700 |
|
|---|
| 701 |
sample_refresh_views (sd->view->sample); |
|---|
| 702 |
} |
|---|
| 703 |
|
|---|
| 704 |
void |
|---|
| 705 |
sd_win_changed_cb (GtkWidget * widget) |
|---|
| 706 |
{ |
|---|
| 707 |
SampleDisplay * sd = SAMPLE_DISPLAY(widget); |
|---|
| 708 |
sw_view * v = sd->view; |
|---|
| 709 |
|
|---|
| 710 |
g_signal_handlers_block_matched (GTK_OBJECT(v->adj), G_SIGNAL_MATCH_DATA, 0, |
|---|
| 711 |
0, 0, 0, v); |
|---|
| 712 |
view_fix_adjustment (sd->view); |
|---|
| 713 |
|
|---|
| 714 |
g_signal_handlers_unblock_matched (GTK_OBJECT(v->adj), G_SIGNAL_MATCH_DATA, 0, |
|---|
| 715 |
0, 0, 0, v); |
|---|
| 716 |
view_refresh_hruler (v); |
|---|
| 717 |
} |
|---|
| 718 |
|
|---|
| 719 |
void |
|---|
| 720 |
adj_changed_cb (GtkWidget * widget, gpointer data) |
|---|
| 721 |
{ |
|---|
| 722 |
sw_view * v = (sw_view *)data; |
|---|
| 723 |
SampleDisplay * sd = SAMPLE_DISPLAY(v->display); |
|---|
| 724 |
GtkAdjustment * adj = GTK_ADJUSTMENT(v->adj); |
|---|
| 725 |
|
|---|
| 726 |
g_signal_handlers_block_matched (GTK_OBJECT(GTK_OBJECT(sd)), G_SIGNAL_MATCH_DATA, 0, |
|---|
| 727 |
0, 0, 0, v); |
|---|
| 728 |
sample_display_set_window(sd, |
|---|
| 729 |
(gint)adj->value, |
|---|
| 730 |
(gint)(adj->value + adj->page_size)); |
|---|
| 731 |
|
|---|
| 732 |
g_signal_handlers_unblock_matched (GTK_OBJECT(GTK_OBJECT(sd)), G_SIGNAL_MATCH_DATA, 0, |
|---|
| 733 |
0, 0, 0, v); |
|---|
| 734 |
view_refresh_hruler (v); |
|---|
| 735 |
} |
|---|
| 736 |
|
|---|
| 737 |
void |
|---|
| 738 |
adj_value_changed_cb (GtkWidget * widget, gpointer data) |
|---|
| 739 |
{ |
|---|
| 740 |
sw_view * v = (sw_view *)data; |
|---|
| 741 |
SampleDisplay * sd = SAMPLE_DISPLAY(v->display); |
|---|
| 742 |
GtkAdjustment * adj = GTK_ADJUSTMENT(v->adj); |
|---|
| 743 |
|
|---|
| 744 |
if (!v->sample->play_head->going || !v->following) { |
|---|
| 745 |
|
|---|
| 746 |
g_signal_handlers_block_matched (GTK_OBJECT(GTK_OBJECT(sd)), G_SIGNAL_MATCH_DATA, 0, |
|---|
| 747 |
0, 0, 0, v); |
|---|
| 748 |
sample_display_set_window(sd, |
|---|
| 749 |
(gint)adj->value, |
|---|
| 750 |
(gint)(adj->value + adj->page_size)); |
|---|
| 751 |
g_signal_handlers_unblock_matched (GTK_OBJECT(GTK_OBJECT(sd)), G_SIGNAL_MATCH_DATA, 0, |
|---|
| 752 |
0, 0, 0, v); |
|---|
| 753 |
} |
|---|
| 754 |
|
|---|
| 755 |
if (v->following) { |
|---|
| 756 |
if (v->sample->user_offset < adj->value || |
|---|
| 757 |
v->sample->user_offset > adj->value + adj->page_size) |
|---|
| 758 |
sample_set_playmarker (v->sample, adj->value + adj->page_size/2, TRUE); |
|---|
| 759 |
} |
|---|
| 760 |
|
|---|
| 761 |
view_refresh_hruler (v); |
|---|
| 762 |
} |
|---|
| 763 |
|
|---|
| 764 |
/* Selection */ |
|---|
| 765 |
|
|---|
| 766 |
void |
|---|
| 767 |
select_invert_cb (GtkWidget * widget, gpointer data) |
|---|
| 768 |
{ |
|---|
| 769 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 770 |
|
|---|
| 771 |
sample_selection_invert (sd->view->sample); |
|---|
| 772 |
} |
|---|
| 773 |
|
|---|
| 774 |
void |
|---|
| 775 |
select_all_cb (GtkWidget * widget, gpointer data) |
|---|
| 776 |
{ |
|---|
| 777 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 778 |
|
|---|
| 779 |
sample_selection_select_all (sd->view->sample); |
|---|
| 780 |
} |
|---|
| 781 |
|
|---|
| 782 |
void |
|---|
| 783 |
select_none_cb (GtkWidget * widget, gpointer data) |
|---|
| 784 |
{ |
|---|
| 785 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 786 |
|
|---|
| 787 |
sample_selection_select_none (sd->view->sample); |
|---|
| 788 |
} |
|---|
| 789 |
|
|---|
| 790 |
void |
|---|
| 791 |
selection_halve_cb (GtkWidget * widget, gpointer data) |
|---|
| 792 |
{ |
|---|
| 793 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 794 |
|
|---|
| 795 |
sample_selection_halve (sd->view->sample); |
|---|
| 796 |
} |
|---|
| 797 |
|
|---|
| 798 |
void |
|---|
| 799 |
selection_double_cb (GtkWidget * widget, gpointer data) |
|---|
| 800 |
{ |
|---|
| 801 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 802 |
|
|---|
| 803 |
sample_selection_double (sd->view->sample); |
|---|
| 804 |
} |
|---|
| 805 |
|
|---|
| 806 |
void |
|---|
| 807 |
select_shift_left_cb (GtkWidget * widget, gpointer data) |
|---|
| 808 |
{ |
|---|
| 809 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 810 |
|
|---|
| 811 |
sample_selection_shift_left (sd->view->sample); |
|---|
| 812 |
} |
|---|
| 813 |
|
|---|
| 814 |
void |
|---|
| 815 |
select_shift_right_cb (GtkWidget * widget, gpointer data) |
|---|
| 816 |
{ |
|---|
| 817 |
SampleDisplay * sd = SAMPLE_DISPLAY(data); |
|---|
| 818 |
|
|---|
| 819 |
sample_selection_shift_right (sd->view->sample); |
|---|
| 820 |
} |
|---|
| 821 |
|
|---|
| 822 |
/* Undo / Redo */ |
|---|
| 823 |
|
|---|
| 824 |
void |
|---|
| 825 |
show_undo_dialog_cb (GtkWidget * widget, gpointer data) |
|---|
| 826 |
{ |
|---|
| 827 |
sw_view * view = (sw_view *)data; |
|---|
| 828 |
|
|---|
| 829 |
undo_dialog_create (view->sample); |
|---|
| 830 |
} |
|---|
| 831 |
|
|---|
| 832 |
void |
|---|
| 833 |
undo_cb (GtkWidget * widget, gpointer data) |
|---|
| 834 |
{ |
|---|
| 835 |
sw_view * view = (sw_view *)data; |
|---|
| 836 |
|
|---|
| 837 |
undo_current (view->sample); |
|---|
| 838 |
} |
|---|
| 839 |
|
|---|
| 840 |
void |
|---|
| 841 |
redo_cb (GtkWidget * widget, gpointer data) |
|---|
| 842 |
{ |
|---|
| 843 |
sw_view * view = (sw_view *)data; |
|---|
| 844 |
|
|---|
| 845 |
redo_current (view->sample); |
|---|
| 846 |
} |
|---|
| 847 |
|
|---|
| 848 |
void |
|---|
| 849 |
cancel_cb (GtkWidget * widget, gpointer data) |
|---|
| 850 |
{ |
|---|
| 851 |
sw_view * view = (sw_view *)data; |
|---|
| 852 |
|
|---|
| 853 |
cancel_active_op (view->sample); |
|---|
| 854 |
} |
|---|
| 855 |
|
|---|
| 856 |
/* Edit */ |
|---|
| 857 |
|
|---|
| 858 |
void |
|---|
| 859 |
copy_cb (GtkWidget * widget, gpointer data) |
|---|
| 860 |
{ |
|---|
| 861 |
sw_view * view = (sw_view *)data; |
|---|
| 862 |
sw_sample * s = view->sample; |
|---|
| 863 |
|
|---|
| 864 |
do_copy (s); |
|---|
| 865 |
} |
|---|
| 866 |
|
|---|
| 867 |
void |
|---|
| 868 |
cut_cb (GtkWidget * widget, gpointer data) |
|---|
| 869 |
{ |
|---|
| 870 |
sw_view * view = (sw_view *)data; |
|---|
| 871 |
sw_sample * s = view->sample; |
|---|
| 872 |
|
|---|
| 873 |
do_cut (s); |
|---|
| 874 |
} |
|---|
| 875 |
|
|---|
| 876 |
void |
|---|
| 877 |
clear_cb (GtkWidget * widget, gpointer data) |
|---|
| 878 |
{ |
|---|
| 879 |
sw_view * view = (sw_view *)data; |
|---|
| 880 |
sw_sample * s = view->sample; |
|---|
| 881 |
|
|---|
| 882 |
do_clear (s); |
|---|
| 883 |
} |
|---|
| 884 |
|
|---|
| 885 |
void |
|---|
| 886 |
delete_cb (GtkWidget * widget, gpointer data) |
|---|
| 887 |
{ |
|---|
| 888 |
sw_view * view = (sw_view *)data; |
|---|
| 889 |
sw_sample * s = view->sample; |
|---|
| 890 |
|
|---|
| 891 |
do_delete (s); |
|---|
| 892 |
} |
|---|
| 893 |
|
|---|
| 894 |
void |
|---|
| 895 |
crop_cb (GtkWidget * widget, gpointer data) |
|---|
| 896 |
{ |
|---|
| 897 |
sw_view * view = (sw_view *)data; |
|---|
| 898 |
sw_sample * s = view->sample; |
|---|
| 899 |
|
|---|
| 900 |
do_crop (s); |
|---|
| 901 |
} |
|---|
| 902 |
|
|---|
| 903 |
void |
|---|
| 904 |
paste_cb (GtkWidget * widget, gpointer data) |
|---|
| 905 |
{ |
|---|
| 906 |
sw_view * view = (sw_view *)data; |
|---|
| 907 |
sw_sample * s = view->sample; |
|---|
| 908 |
|
|---|
| 909 |
do_paste_insert (s); |
|---|
| 910 |
} |
|---|
| 911 |
|
|---|
| 912 |
void |
|---|
| 913 |
paste_mix_cb (GtkWidget * widget, gpointer data) |
|---|
| 914 |
{ |
|---|
| 915 |
sw_view * view = (sw_view *)data; |
|---|
| 916 |
sw_sample * s = view->sample; |
|---|
| 917 |
|
|---|
| 918 |
if (clipboard_width() > 0) { |
|---|
| 919 |
create_paste_mix_dialog (s); |
|---|
| 920 |
} else { |
|---|
| 921 |
sample_set_tmp_message (s, _("Clipboard empty")); |
|---|
| 922 |
} |
|---|
| 923 |
} |
|---|
| 924 |
|
|---|
| 925 |
void |
|---|
| 926 |
paste_xfade_cb (GtkWidget * widget, gpointer data) |
|---|
| 927 |
{ |
|---|
| 928 |
sw_view * view = (sw_view *)data; |
|---|
| 929 |
sw_sample * s = view->sample; |
|---|
| 930 |
|
|---|
| 931 |
if (clipboard_width() > 0) { |
|---|
| 932 |
create_paste_xfade_dialog (s); |
|---|
| 933 |
} else { |
|---|
| 934 |
sample_set_tmp_message (s, _("Clipboard empty")); |
|---|
| 935 |
} |
|---|
| 936 |
} |
|---|
| 937 |
|
|---|
| 938 |
void |
|---|
| 939 |
paste_as_new_cb (GtkWidget * widget, gpointer data) |
|---|
| 940 |
{ |
|---|
| 941 |
sw_sample * s; |
|---|
| 942 |
sw_view * v; |
|---|
| 943 |
|
|---|
| 944 |
s = do_paste_as_new (); |
|---|
| 945 |
|
|---|
| 946 |
if (s) { |
|---|
| 947 |
v = view_new_all (s, 1.0); |
|---|
| 948 |
sample_add_view (s, v); |
|---|
| 949 |
sample_bank_add (s); |
|---|
| 950 |
} |
|---|
| 951 |
} |
|---|
| 952 |
|
|---|
| 953 |
void |
|---|
| 954 |
show_info_dialog_cb (GtkWidget * widget, gpointer data) |
|---|
| 955 |
{ |
|---|
| 956 |
sw_view * view = (sw_view *)data; |
|---|
| 957 |
|
|---|
| 958 |
sample_show_info_dialog (view->sample); |
|---|
| 959 |
} |
|---|
| 960 |
|
|---|
| 961 |
void |
|---|
| 962 |
hide_window_cb (GtkAccelGroup *accel_group, |
|---|
| 963 |
GObject *acceleratable, |
|---|
| 964 |
guint keyval, |
|---|
| 965 |
GdkModifierType modifier) |
|---|
| 966 |
{ |
|---|
| 967 |
if (GTK_IS_WINDOW(acceleratable)) |
|---|
| 968 |
g_signal_emit_by_name(G_OBJECT(acceleratable), "hide"); |
|---|
| 969 |
} |
|---|
| 970 |
|
|---|
| 971 |
void |
|---|
| 972 |
close_window_cb (GtkAccelGroup *accel_group, |
|---|
| 973 |
GObject *acceleratable, |
|---|
| 974 |
guint keyval, |
|---|
| 975 |
GdkModifierType modifier) |
|---|
| 976 |
{ |
|---|
| 977 |
if (GTK_IS_WINDOW(acceleratable)) |
|---|
| 978 |
g_signal_emit_by_name(G_OBJECT(acceleratable), "destroy"); |
|---|
| 979 |
} |
|---|
| 980 |
|
|---|
| 981 |
/* |
|---|
| 982 |
* Prime the label with the largest string then fetch the width. |
|---|
| 983 |
* now we can lock the width via gtk_widget_set_usize() to prevent |
|---|
| 984 |
* the wobble wobble caused by using a variable width font. |
|---|
| 985 |
* Just a hackish replacement for the belated gtk_label_set_width_chars() |
|---|
| 986 |
* don't try this at home kids, karma will get you. (oh well.. it works.) |
|---|
| 987 |
*/ |
|---|
| 988 |
void |
|---|
| 989 |
hack_max_label_width_cb (GtkWidget *widget, |
|---|
| 990 |
GtkStyle *previous_style, |
|---|
| 991 |
gpointer user_data) |
|---|
| 992 |
{ |
|---|
| 993 |
PangoRectangle logical_rect, ink_rect; |
|---|
| 994 |
const gchar *saved; |
|---|
| 995 |
|
|---|
| 996 |
if (!GTK_IS_LABEL(widget)) |
|---|
| 997 |
return; |
|---|
| 998 |
saved = strdup(gtk_label_get_text(GTK_LABEL(widget))); |
|---|
| 999 |
gtk_label_set_text(GTK_LABEL(widget), "00:00:00.0000"); |
|---|
| 1000 |
pango_layout_get_extents (gtk_label_get_layout (GTK_LABEL(widget)), &ink_rect, &logical_rect); |
|---|
| 1001 |
gtk_label_set_text(GTK_LABEL(widget), saved); |
|---|
| 1002 |
|
|---|
| 1003 |
if(saved != NULL) |
|---|
| 1004 |
g_free((gpointer)saved); |
|---|
| 1005 |
gtk_widget_set_usize(GTK_WIDGET(widget), PANGO_PIXELS (ink_rect.width), -1); |
|---|
| 1006 |
} |
|---|
| 1007 |
|
|---|
| 1008 |
void |
|---|
| 1009 |
hack_max_combo_width_cb (GtkWidget *widget, |
|---|
| 1010 |
GtkStyle *previous_style, |
|---|
| 1011 |
gpointer user_data) |
|---|
| 1012 |
{ |
|---|
| 1013 |
PangoRectangle logical_rect, ink_rect; |
|---|
| 1014 |
GtkWidget *tmp_entry; |
|---|
| 1015 |
|
|---|
| 1016 |
if (!GTK_IS_ENTRY(widget)) |
|---|
| 1017 |
return; |
|---|
| 1018 |
tmp_entry = gtk_entry_new(); |
|---|
| 1019 |
gtk_widget_set_style(tmp_entry, gtk_style_copy(widget->style)); |
|---|
| 1020 |
gtk_entry_set_text(GTK_ENTRY(tmp_entry), "00:00:00.0000."); |
|---|
| 1021 |
|
|---|
| 1022 |
pango_layout_get_extents (gtk_entry_get_layout (GTK_ENTRY(tmp_entry)), &ink_rect, &logical_rect); |
|---|
| 1023 |
gtk_widget_destroy(tmp_entry); |
|---|
| 1024 |
|
|---|
| 1025 |
gtk_widget_set_usize(GTK_WIDGET(GTK_ENTRY(widget)), PANGO_PIXELS (ink_rect.width), -1); |
|---|
| 1026 |
} |
|---|
| 1027 |
|
|---|
| 1028 |
#if GTK_CHECK_VERSION (2, 10, 0) |
|---|
| 1029 |
|
|---|
| 1030 |
void |
|---|
| 1031 |
recent_chooser_menu_activated_cb(GtkRecentChooser *chooser, |
|---|
| 1032 |
gpointer user_data) |
|---|
| 1033 |
{ |
|---|
| 1034 |
gchar *uri = NULL; |
|---|
| 1035 |
gchar *path = NULL; |
|---|
| 1036 |
|
|---|
| 1037 |
uri = gtk_recent_chooser_get_current_uri(chooser); |
|---|
| 1038 |
path = g_filename_from_uri(uri, NULL, NULL); |
|---|
| 1039 |
sample_load(path); |
|---|
| 1040 |
|
|---|
| 1041 |
g_free (path); |
|---|
| 1042 |
} |
|---|
| 1043 |
|
|---|
| 1044 |
#endif |
|---|