void Todo::highlight_note() { Gtk::TextIter start = get_buffer()->get_iter_at_offset(0); Gtk::TextIter end = start; end.forward_to_end(); highlight_region(start, end); }
static int tolua_highlight_region(lua_State * L) { region *r = (region *)tolua_tousertype(L, 1, 0); int select = tolua_toboolean(L, 2, 0); highlight_region(r, select); return 0; }
void Todo::highlight_region(Gtk::TextIter start, Gtk::TextIter end) { if(!start.starts_line()) { start.backward_line(); } if(!end.ends_line()) { end.forward_line(); } FOREACH(const std::string & pattern, s_todo_patterns) { highlight_region(pattern, start, end); }
static void region_focus_callback(GtkWidget *w, gpointer context) /* button clicked callback */ { chan_info *cp; regrow *r = (regrow *)context; unhighlight_region(); if (region_list_position_to_id(r->pos) == INVALID_REGION) return; /* needed by auto-tester */ set_current_region(r->pos); cp = rsp->chans[0]; cp->sound = rsp; cp->chan = 0; highlight_region(); set_sensitive(channel_f(cp), false); set_sensitive(channel_w(cp), (region_chans(region_list_position_to_id(current_region)) > 1)); rsp->hdr = fixup_region_data(cp, 0, current_region); make_region_labels(rsp->hdr); region_update_graph(cp); }
void delete_region_and_update_browser(int pos) { int act; unhighlight_region(); act = remove_region_from_list(pos); if (act == INVALID_REGION) return; if (region_dialog) { if (act != NO_REGIONS) { set_current_region(0); highlight_region(); goto_window(region_rows[0]->nm); } else set_current_region(-1); update_region_browser(true); } }
void update_region_browser(bool grf_too) { int i, len; region_state *rs; rs = region_report(); len = rs->len; for (i = 0; i < len; i++) { regrow *r; r = region_row(i); set_button_label(r->nm, rs->name[i]); set_toggle_button(r->pl, false, false, (void *)r); gtk_widget_show(r->rw); } for (i = len; i < max_regions(ss); i++) if (region_rows[i]) gtk_widget_hide(region_rows[i]->rw); free_region_state(rs); if (len == 0) return; gtk_widget_show(region_list); if (grf_too) { chan_info *cp; unhighlight_region(); set_current_region(0); highlight_region(); goto_window(region_rows[0]->nm); cp = rsp->chans[0]; if (cp) { cp->sound = rsp; cp->chan = 0; set_sensitive(channel_f(cp), false); set_sensitive(channel_w(cp), (region_chans(region_list_position_to_id(0)) > 1)); rsp->hdr = fixup_region_data(cp, 0, 0); make_region_labels(rsp->hdr); region_update_graph(cp); } } }
void Todo::on_delete_range(const Gtk::TextBuffer::iterator & start, const Gtk::TextBuffer::iterator & end) { highlight_region(start, end); }
void Todo::on_insert_text(const Gtk::TextIter & pos, const Glib::ustring & /*text*/, int /*bytes*/) { highlight_region(pos, pos); }
static void make_region_dialog(void) { int i, id; regrow *r; chan_info *cp; GtkWidget *infobox, *labels, *labbox; GtkWidget *sep1, *cww, *toppane, *tophbox, *plw, *formw; region_dialog = snd_gtk_dialog_new(); SG_SIGNAL_CONNECT(region_dialog, "delete_event", region_browser_delete_callback, NULL); gtk_window_set_title(GTK_WINDOW(region_dialog), _("Regions")); sg_make_resizable(region_dialog); gtk_container_set_border_width(GTK_CONTAINER(region_dialog), 10); gtk_window_resize(GTK_WINDOW(region_dialog), 400, 500); gtk_widget_realize(region_dialog); help_button = gtk_button_new_from_stock(GTK_STOCK_HELP); gtk_widget_set_name(help_button, "help_button"); dismiss_button = gtk_button_new_from_stock(GTK_STOCK_QUIT); gtk_widget_set_name(dismiss_button, "quit_button"); insert_button = sg_button_new_from_stock_with_label(_("Insert"), GTK_STOCK_PASTE); gtk_widget_set_name(insert_button, "doit_button"); mix_button = sg_button_new_from_stock_with_label(_("Mix"), GTK_STOCK_ADD); gtk_widget_set_name(mix_button, "doit_again_button"); save_as_button = gtk_button_new_from_stock(GTK_STOCK_SAVE_AS); gtk_widget_set_name(save_as_button, "reset_button"); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(region_dialog)->action_area), dismiss_button, true, true, 4); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(region_dialog)->action_area), insert_button, true, true, 4); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(region_dialog)->action_area), mix_button, true, true, 4); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(region_dialog)->action_area), save_as_button, true, true, 4); gtk_box_pack_end(GTK_BOX(GTK_DIALOG(region_dialog)->action_area), help_button, true, true, 4); SG_SIGNAL_CONNECT(insert_button, "clicked", region_insert_callback, NULL); SG_SIGNAL_CONNECT(mix_button, "clicked", region_mix_callback, NULL); SG_SIGNAL_CONNECT(help_button, "clicked", region_help_callback, NULL); SG_SIGNAL_CONNECT(dismiss_button, "clicked", region_ok_callback, NULL); SG_SIGNAL_CONNECT(save_as_button, "clicked", region_save_callback, NULL); gtk_widget_show(insert_button); gtk_widget_show(mix_button); gtk_widget_show(help_button); gtk_widget_show(dismiss_button); gtk_widget_show(save_as_button); region_grf = gtk_vpaned_new(); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(region_dialog)->vbox), region_grf, true, true, 0); gtk_widget_show(region_grf); toppane = gtk_hbox_new(false, 0); gtk_paned_add1(GTK_PANED(region_grf), toppane); gtk_widget_show(toppane); formw = gtk_vbox_new(false, 0); gtk_box_pack_start(GTK_BOX(toppane), formw, true, true, 4); gtk_widget_show(formw); sep1 = gtk_vseparator_new(); /* not hsep -- damned thing insists on drawing a line */ gtk_box_pack_start(GTK_BOX(formw), sep1, false, false, 2); gtk_widget_show(sep1); tophbox = gtk_hbox_new(false, 0); gtk_box_pack_start(GTK_BOX(formw), tophbox, false, false, 4); gtk_widget_show(tophbox); plw = gtk_label_new(_("play")); gtk_box_pack_start(GTK_BOX(tophbox), plw, false, false, 2); gtk_widget_show(plw); sep1 = gtk_vseparator_new(); gtk_box_pack_start(GTK_BOX(formw), sep1, false, false, 2); gtk_widget_show(sep1); region_list = gtk_vbox_new(false, 0); cww = gtk_scrolled_window_new(NULL, NULL); gtk_box_pack_start(GTK_BOX(formw), cww, true, true, 0); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(cww), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(cww), region_list); gtk_widget_show(region_list); gtk_widget_show(cww); infobox = gtk_vbox_new(false, 0); gtk_box_pack_start(GTK_BOX(toppane), infobox, false, false, 2); gtk_widget_show(infobox); region_rows = (regrow **)CALLOC(max_regions(ss), sizeof(regrow *)); region_rows_size = max_regions(ss); for (i = 0; i < max_regions(ss); i++) { r = make_regrow(region_list, (void (*)())region_play_callback, (void (*)())region_focus_callback); region_rows[i] = r; r->pos = i; } update_region_browser(false); /* in Gtk, apparently, labels are just the text, not the background (i.e. they're transparent) */ /* we need a button simply to get the background color, then a vbox to put four labels on the button */ /* but we get a button which flashes whenever the mouse comes near it and has "relief" */ /* if we turn off the relief, the colors go away */ /* all I want is an opaque label with a background color */ labels = gtk_button_new(); gtk_box_pack_start(GTK_BOX(infobox), labels, true, true, 2); gtk_widget_show(labels); gtk_widget_modify_bg(labels, GTK_STATE_NORMAL, ss->sgx->highlight_color); SG_SIGNAL_CONNECT(labels, "enter_notify_event", region_labels_mouse_enter, NULL); labbox = gtk_vbox_new(true, 0); gtk_container_add(GTK_CONTAINER(labels), labbox); gtk_widget_show(labbox); gtk_widget_modify_bg(labbox, GTK_STATE_NORMAL, ss->sgx->highlight_color); srate_text = gtk_label_new(_("srate:")); sg_left_justify_label(srate_text); gtk_box_pack_start(GTK_BOX(labbox), srate_text, false, false, 2); gtk_widget_show(srate_text); chans_text = gtk_label_new(_("chans:")); sg_left_justify_label(chans_text); gtk_box_pack_start(GTK_BOX(labbox), chans_text, false, false, 2); gtk_widget_show(chans_text); length_text = gtk_label_new(_("length:")); sg_left_justify_label(length_text); gtk_box_pack_start(GTK_BOX(labbox), length_text, false, false, 2); gtk_widget_show(length_text); maxamp_text = gtk_label_new(_("maxamp:")); sg_left_justify_label(maxamp_text); gtk_box_pack_start(GTK_BOX(labbox), maxamp_text, false, false, 2); gtk_widget_show(maxamp_text); edit_button = gtk_button_new_with_label(_("edit")); SG_SIGNAL_CONNECT(edit_button, "clicked", region_edit_callback, NULL); gtk_box_pack_start(GTK_BOX(infobox), edit_button, true, true, 2); gtk_widget_show(edit_button); gtk_widget_modify_bg(edit_button, GTK_STATE_NORMAL, ss->sgx->lighter_blue); gtk_widget_modify_bg(edit_button, GTK_STATE_ACTIVE, ss->sgx->red); print_button = gtk_button_new_with_label(_("print")); SG_SIGNAL_CONNECT(print_button, "clicked", region_print_callback, NULL); gtk_box_pack_start(GTK_BOX(infobox), print_button, true, true, 2); gtk_widget_show(print_button); gtk_widget_modify_bg(print_button, GTK_STATE_NORMAL, ss->sgx->lighter_blue); gtk_widget_modify_bg(print_button, GTK_STATE_ACTIVE, ss->sgx->red); unlist_button = gtk_button_new_with_label(_("unlist")); SG_SIGNAL_CONNECT(unlist_button, "clicked", region_unlist_callback, NULL); gtk_box_pack_start(GTK_BOX(infobox), unlist_button, true, true, 2); gtk_widget_show(unlist_button); gtk_widget_modify_bg(unlist_button, GTK_STATE_NORMAL, ss->sgx->lighter_blue); gtk_widget_modify_bg(unlist_button, GTK_STATE_ACTIVE, ss->sgx->red); gtk_widget_show(region_dialog); id = region_list_position_to_id(0); rsp = make_simple_channel_display(region_srate(id), region_len(id), WITH_ARROWS, region_graph_style(ss), region_grf, WITHOUT_EVENTS); rsp->inuse = SOUND_REGION; set_current_region(0); cp = rsp->chans[0]; gtk_paned_set_position(GTK_PANED(region_grf), 220); SG_SIGNAL_CONNECT(channel_graph(cp), "expose_event", region_resize_callback, cp); SG_SIGNAL_CONNECT(channel_graph(cp), "configure_event", region_expose_callback, cp); SG_SIGNAL_CONNECT(channel_up_arrow(cp), "button_press_event", region_up_arrow_callback, NULL); SG_SIGNAL_CONNECT(channel_down_arrow(cp), "button_press_event", region_down_arrow_callback, NULL); set_sensitive(channel_f(cp), false); if (region_chans(region_list_position_to_id(0)) > 1) set_sensitive(channel_w(cp), true); cp->chan = 0; rsp->hdr = fixup_region_data(cp, 0, 0); make_region_labels(rsp->hdr); highlight_region(); region_update_graph(cp); add_ss_watcher(SS_FILE_OPEN_WATCHER, reflect_file_in_region_browser, NULL); set_dialog_widget(REGION_DIALOG, region_dialog); }